home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / dspack / DSPACK231.exe / {app} / src / DirectX9 / D3DX8.pas next >
Encoding:
Pascal/Delphi Source File  |  2003-04-27  |  175.0 KB  |  4,952 lines

  1. {******************************************************************************}
  2. {*                                                                            *}
  3. {*  Copyright (C) Microsoft Corporation.  All Rights Reserved.                *}
  4. {*                                                                            *}
  5. {*  File:       d3dx8.h, d3dx8core.h, d3dx8math.h, d3dx8math.inl,             *}
  6. {*              d3dx8effect.h, d3dx8mesh.h, d3dx8shape.h, d3dx8tex.h          *}
  7. {*  Content:    Direct3DX 8.1 headers                                         *}
  8. {*                                                                            *}
  9. {*  Direct3DX 8.1 Delphi adaptation by Alexey Barkovoy                        *}
  10. {*  E-Mail: clootie@reactor.ru                                                *}
  11. {*                                                                            *}
  12. {*  Modified: 27-Apr-2003                                                     *}
  13. {*                                                                            *}
  14. {*  Partly based upon :                                                       *}
  15. {*    Direct3DX 7.0 Delphi adaptation by                                      *}
  16. {*      Arne SchΣpers, e-Mail: [look at www.delphi-jedi.org/DelphiGraphics/]  *}
  17. {*                                                                            *}
  18. {*  Latest version can be downloaded from:                                    *}
  19. {*     http://clootie.narod.ru/delphi                                         *}
  20. {*                                                                            *}
  21. {*  This File contains only Direct3DX 8.x Definitions.                        *}
  22. {*  If you want to use D3DX7 version of D3DX use translation by Arne SchΣpers *}
  23. {*                                                                            *}
  24. {******************************************************************************)
  25. {                                                                              }
  26. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
  27. {                                                                              }
  28. { The contents of this file are used with permission, subject to the Mozilla   }
  29. { Public License Version 1.1 (the "License"); you may not use this file except }
  30. { in compliance with the License. You may obtain a copy of the License at      }
  31. { http://www.mozilla.org/MPL/MPL-1.1.html                                      }
  32. {                                                                              }
  33. { Software distributed under the License is distributed on an "AS IS" basis,   }
  34. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  35. { the specific language governing rights and limitations under the License.    }
  36. {                                                                              }
  37. { Alternatively, the contents of this file may be used under the terms of the  }
  38. { GNU Lesser General Public License (the  "LGPL License"), in which case the   }
  39. { provisions of the LGPL License are applicable instead of those above.        }
  40. { If you wish to allow use of your version of this file only under the terms   }
  41. { of the LGPL License and not to allow others to use your version of this file }
  42. { under the MPL, indicate your decision by deleting  the provisions above and  }
  43. { replace  them with the notice and other provisions required by the LGPL      }
  44. { License.  If you do not delete the provisions above, a recipient may use     }
  45. { your version of this file under either the MPL or the LGPL License.          }
  46. {                                                                              }
  47. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  48. {                                                                              }
  49. {******************************************************************************}
  50.  
  51. // Original source contained in "D3DX8.par"
  52.  
  53. {$I DirectX.inc}
  54.  
  55. unit D3DX8;
  56.  
  57. interface
  58.  
  59. // Remove "dot" below to link with debug version of D3DX8
  60. // (only in JEDI or TMT pascal version)
  61. {.$DEFINE DEBUG}
  62.  
  63. // Remove "dot" below to link with DirectXGraphics and Direct3D
  64. {.$DEFINE DXG_COMPAT}
  65.  
  66. (*$HPPEMIT '#include "d3dx8.h"' *)
  67. (*$HPPEMIT '#include "dxfile.h"' *)
  68.  
  69. // Do not emit <DXFile.hpp> to C++Builder
  70. (*$NOINCLUDE DXFile *)
  71.  
  72. (*$HPPEMIT 'namespace D3dx8' *)
  73.  
  74. (*$HPPEMIT '{' *)
  75.  
  76. uses
  77.   Windows,
  78.   ActiveX,
  79.   SysUtils,
  80.   {$I UseD3D8.inc},
  81.   DXFile;
  82.  
  83. const
  84.   //////////// DLL export definitions ///////////////////////////////////////
  85.   d3dx8dll ={$IFDEF DEBUG} 'd3dx8d.dll'{$ELSE} 'D3DX81ab.dll'{$ENDIF};
  86.  
  87.  
  88. ///////////////////////////////////////////////////////////////////////////
  89. //
  90. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  91. //
  92. //  File:       d3dx8.h
  93. //  Content:    D3DX utility library
  94. //
  95. ///////////////////////////////////////////////////////////////////////////
  96.  
  97. const
  98.   // #define D3DX_DEFAULT ULONG_MAX
  99.   D3DX_DEFAULT          = $FFFFFFFF;
  100.   {$EXTERNALSYM D3DX_DEFAULT}
  101.  
  102. var
  103.   // #define D3DX_DEFAULT_FLOAT FLT_MAX
  104.   // Forced to define as 'var' cos pascal compiler treats all consts as Double
  105.   D3DX_DEFAULT_FLOAT: Single = 3.402823466e+38;  // max single value
  106.   {$EXTERNALSYM D3DX_DEFAULT_FLOAT}
  107.  
  108.  
  109.  
  110.  
  111. //////////////////////////////////////////////////////////////////////////////
  112. //
  113. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  114. //
  115. //  File:       d3dx8math.h
  116. //  Content:    D3DX math types and functions
  117. //
  118. //////////////////////////////////////////////////////////////////////////////
  119.  
  120. //===========================================================================
  121. //
  122. // General purpose utilities
  123. //
  124. //===========================================================================
  125. const
  126.   D3DX_PI: Single       = 3.141592654;
  127.   {$EXTERNALSYM D3DX_PI}
  128.   D3DX_1BYPI: Single    = 0.318309886;
  129.   {$EXTERNALSYM D3DX_1BYPI}
  130.  
  131. //#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f))
  132. function D3DXToRadian(Degree: Single): Single;
  133. {$EXTERNALSYM D3DXToRadian}
  134. //#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI))
  135. function D3DXToDegree(Radian: Single): Single;
  136. {$EXTERNALSYM D3DXToDegree}
  137.  
  138.  
  139. //===========================================================================
  140. //
  141. // Vectors
  142. //
  143. //===========================================================================
  144.  
  145. //--------------------------
  146. // 2D Vector
  147. //--------------------------
  148. type
  149.   {$HPPEMIT 'typedef D3DXVECTOR2 TD3DXVector2;'}
  150.   {$HPPEMIT 'typedef D3DXVECTOR2 *PD3DXVector2;'}
  151.   PD3DXVector2 = ^TD3DXVector2;
  152.   {$NODEFINE PD3DXVector2}
  153.   TD3DXVector2 = packed record
  154.     x, y: Single;
  155.   end;
  156.   {$NODEFINE TD3DXVector2}
  157.  
  158. // Some pascal equalents of C++ class functions & operators
  159. const D3DXVector2Zero: TD3DXVector2 = (x:0; y:0);  // (0,0)
  160. function D3DXVector2(_x, _y: Single): TD3DXVector2;
  161. function D3DXVector2Equal(const v1, v2: TD3DXVector2): Boolean;
  162.  
  163.  
  164. //--------------------------
  165. // 3D Vector
  166. //--------------------------
  167. type
  168.   {$HPPEMIT 'typedef D3DXVECTOR3 TD3DXVector3;'}
  169.   {$HPPEMIT 'typedef D3DXVECTOR3 *PD3DXVector3;'}
  170.   PD3DXVector3 = ^TD3DXVector3;
  171.   {$NODEFINE PD3DXVector3}
  172.   TD3DXVector3 = TD3DVector;
  173.   {$NODEFINE TD3DXVector3}
  174.  
  175. // Some pascal equalents of C++ class functions & operators
  176. const D3DXVector3Zero: TD3DXVector3 = (x:0; y:0; z:0);  // (0,0,0)
  177. function D3DXVector3(_x, _y, _z: Single): TD3DXVector3;
  178. function D3DXVector3Equal(const v1, v2: TD3DXVector3): Boolean;
  179.  
  180.  
  181. //--------------------------
  182. // 4D Vector
  183. //--------------------------
  184. type
  185.   {$HPPEMIT 'typedef D3DXVECTOR4 TD3DXVector4;'}
  186.   {$HPPEMIT 'typedef D3DXVECTOR4 *PD3DXVector4;'}
  187.   PD3DXVector4 = ^TD3DXVector4;
  188.   {$NODEFINE PD3DXVector4}
  189.   TD3DXVector4 = packed record
  190.     x, y, z, w: Single;
  191.   end;
  192.   {$NODEFINE TD3DXVector4}
  193.  
  194. // Some pascal equalents of C++ class functions & operators
  195. const D3DXVector4Zero: TD3DXVector4 = (x:0; y:0; z:0; w:0);  // (0,0,0,0)
  196. function D3DXVector4(_x, _y, _z, _w: Single): TD3DXVector4;
  197. function D3DXVector4Equal(const v1, v2: TD3DXVector4): Boolean;
  198.  
  199. //===========================================================================
  200. //
  201. // Matrices
  202. //
  203. //===========================================================================
  204. type
  205.   {$HPPEMIT 'typedef D3DXMATRIX TD3DXMatrix;'}
  206.   {$HPPEMIT 'typedef D3DXMATRIX *PD3DXMatrix;'}
  207.   PD3DXMatrix = ^TD3DXMatrix;
  208.   {$NODEFINE PD3DXMatrix}
  209.   TD3DXMatrix = TD3DMatrix;
  210.   {$NODEFINE TD3DXMatrix}
  211.  
  212. // Some pascal equalents of C++ class functions & operators
  213. function D3DXMatrix(
  214.   _m00, _m01, _m02, _m03,
  215.   _m10, _m11, _m12, _m13,
  216.   _m20, _m21, _m22, _m23,
  217.   _m30, _m31, _m32, _m33: Single): TD3DXMatrix;
  218. function D3DXMatrixAdd(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  219. function D3DXMatrixSubtract(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  220. function D3DXMatrixMul(out mOut: TD3DXMatrix; const m: TD3DXMatrix; MulBy: Single): PD3DXMatrix;
  221. function D3DXMatrixEqual(const m1, m2: TD3DXMatrix): Boolean;
  222.  
  223.  
  224. //===========================================================================
  225. //
  226. // Aligned Matrices
  227. //
  228. // This class helps keep matrices 16-byte aligned as preferred by P4 cpus.
  229. // It aligns matrices on the stack and on the heap or in global scope.
  230. // It does this using __declspec(align(16)) which works on VC7 and on VC 6
  231. // with the processor pack. Unfortunately there is no way to detect the
  232. // latter so this is turned on only on VC7. On other compilers this is the
  233. // the same as D3DXMATRIX.
  234. // Using this class on a compiler that does not actually do the alignment
  235. // can be dangerous since it will not expose bugs that ignore alignment.
  236. // E.g if an object of this class in inside a struct or class, and some code
  237. // memcopys data in it assuming tight packing. This could break on a compiler
  238. // that eventually start aligning the matrix.
  239. //
  240. //===========================================================================
  241.  
  242. // Translator comments: None of current pascal compilers can even align data
  243. // inside records to 16 byte boundary, so we just leave aligned matrix
  244. // declaration equal to standart matrix
  245. type
  246.   PD3DXMatrixA16 = ^TD3DXMatrixA16;
  247.   TD3DXMatrixA16 = TD3DXMatrix;
  248.  
  249.  
  250. //===========================================================================
  251. //
  252. //    Quaternions
  253. //
  254. //===========================================================================
  255. type
  256.   PD3DXQuaternion = ^TD3DXQuaternion;
  257.   TD3DXQuaternion = packed record
  258.     x, y, z, w: Single;
  259.   end;
  260.   {$NODEFINE TD3DXQuaternion}
  261.   {$HPPEMIT 'typedef D3DXQUATERNION TD3DXQuaternion;'}
  262.  
  263. // Some pascal equalents of C++ class functions & operators
  264. function D3DXQuaternion(_x, _y, _z, _w: Single): TD3DXQuaternion;
  265. function D3DXQuaternionAdd(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  266. function D3DXQuaternionSubtract(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  267. function D3DXQuaternionEqual(const q1, q2: TD3DXQuaternion): Boolean;
  268. function D3DXQuaternionScale(out qOut: TD3DXQuaternion; const q: TD3DXQuaternion;
  269.   s: Single): PD3DXQuaternion;
  270.  
  271.  
  272. //===========================================================================
  273. //
  274. // Planes
  275. //
  276. //===========================================================================
  277. type
  278.   PD3DXPlane = ^TD3DXPlane;
  279.   TD3DXPlane = packed record
  280.     a, b, c, d: Single;
  281.   end;
  282.   {$NODEFINE TD3DXPlane}
  283.   {$HPPEMIT 'typedef D3DXPLANE TD3DXPlane;'}
  284.  
  285. // Some pascal equalents of C++ class functions & operators
  286. const D3DXPlaneZero: TD3DXPlane = (a:0; b:0; c:0; d:0);  // (0,0,0,0)
  287. function D3DXPlane(_a, _b, _c, _d: Single): TD3DXPlane;
  288. function D3DXPlaneEqual(const p1, p2: TD3DXPlane): Boolean;
  289.  
  290.  
  291. //===========================================================================
  292. //
  293. // Colors
  294. //
  295. //===========================================================================
  296. type
  297.   {$HPPEMIT 'typedef D3DXCOLOR TD3DXColor;'}
  298.   {$HPPEMIT 'typedef D3DXCOLOR *PD3DXColor;'}
  299.   PD3DXColor = PD3DColorValue;
  300.   {$NODEFINE PD3DXColor}
  301.   TD3DXColor = TD3DColorValue;
  302.   {$NODEFINE TD3DXColor}
  303.  
  304. function D3DXColor(_r, _g, _b, _a: Single): TD3DXColor;
  305. function D3DXColorToDWord(c: TD3DXColor): DWord;
  306. function D3DXColorFromDWord(c: DWord): TD3DXColor;
  307. function D3DXColorEqual(const c1, c2: TD3DXColor): Boolean;
  308.  
  309.  
  310. //===========================================================================
  311. //
  312. // D3DX math functions:
  313. //
  314. // NOTE:
  315. //  * All these functions can take the same object as in and out parameters.
  316. //
  317. //  * Out parameters are typically also returned as return values, so that
  318. //    the output of one function may be used as a parameter to another.
  319. //
  320. //===========================================================================
  321.  
  322. //--------------------------
  323. // 2D Vector
  324. //--------------------------
  325.  
  326. // inline
  327.  
  328. function D3DXVec2Length(const v: TD3DXVector2): Single;
  329. {$EXTERNALSYM D3DXVec2Length}
  330.  
  331. function D3DXVec2LengthSq(const v: TD3DXVector2): Single;
  332. {$EXTERNALSYM D3DXVec2LengthSq}
  333.  
  334. function D3DXVec2Dot(const v1, v2: TD3DXVector2): Single;
  335. {$EXTERNALSYM D3DXVec2Dot}
  336.  
  337. // Z component of ((x1,y1,0) cross (x2,y2,0))
  338. function D3DXVec2CCW(const v1, v2: TD3DXVector2): Single;
  339. {$EXTERNALSYM D3DXVec2CCW}
  340.  
  341. function D3DXVec2Add(const v1, v2: TD3DXVector2): TD3DXVector2;
  342. {$EXTERNALSYM D3DXVec2Add}
  343.  
  344. function D3DXVec2Subtract(const v1, v2: TD3DXVector2): TD3DXVector2;
  345. {$EXTERNALSYM D3DXVec2Subtract}
  346.  
  347. // Minimize each component.  x = min(x1, x2), y = min(y1, y2)
  348. function D3DXVec2Minimize(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2): PD3DXVector2;
  349. {$EXTERNALSYM D3DXVec2Minimize}
  350.  
  351. // Maximize each component.  x = max(x1, x2), y = max(y1, y2)
  352. function D3DXVec2Maximize(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2): PD3DXVector2;
  353. {$EXTERNALSYM D3DXVec2Maximize}
  354.  
  355. function D3DXVec2Scale(out vOut: TD3DXVector2; const v: TD3DXVector2; s: Single): PD3DXVector2;
  356. {$EXTERNALSYM D3DXVec2Scale}
  357.  
  358. // Linear interpolation. V1 + s(V2-V1)
  359. function D3DXVec2Lerp(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2; s: Single): PD3DXVector2;
  360. {$EXTERNALSYM D3DXVec2Lerp}
  361.  
  362. // non-inline
  363. function D3DXVec2Normalize(out vOut: TD3DXVector2; const v: TD3DXVector2): PD3DXVector2; stdcall; external d3dx8dll;
  364. {$EXTERNALSYM D3DXVec2Normalize}
  365.  
  366. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  367. // and position V2, tangent T2 (when s == 1).
  368. function D3DXVec2Hermite(out vOut: TD3DXVector2;
  369.    const v1, t1, v2, t2: TD3DXVector2; s: Single): PD3DXVector2; stdcall; external d3dx8dll;
  370. {$EXTERNALSYM D3DXVec2Hermite}
  371.  
  372. // CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
  373. function D3DXVec2CatmullRom(out vOut: TD3DXVector2;
  374.    const v0, v1, v2: TD3DXVector2; s: Single): PD3DXVector2; stdcall; external d3dx8dll;
  375. {$EXTERNALSYM D3DXVec2CatmullRom}
  376.  
  377. // Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
  378. function D3DXVec2BaryCentric(out vOut: TD3DXVector2;
  379.    const v1, v2, v3: TD3DXVector2; f, g: Single): PD3DXVector2; stdcall; external d3dx8dll;
  380. {$EXTERNALSYM D3DXVec2BaryCentric}
  381.  
  382. // Transform (x, y, 0, 1) by matrix.
  383. function D3DXVec2Transform(out vOut: TD3DXVector4;
  384.   const v: TD3DXVector2; const m: TD3DXMatrix): PD3DXVector4; stdcall; external d3dx8dll;
  385. {$EXTERNALSYM D3DXVec2Transform}
  386.  
  387. // Transform (x, y, 0, 1) by matrix, project result back into w=1.
  388. function D3DXVec2TransformCoord(out vOut: TD3DXVector2;
  389.   const v: TD3DXVector2; const m: TD3DXMatrix): PD3DXVector2; stdcall; external d3dx8dll;
  390. {$EXTERNALSYM D3DXVec2TransformCoord}
  391.  
  392. // Transform (x, y, 0, 0) by matrix.
  393. function D3DXVec2TransformNormal(out vOut: TD3DXVector2;
  394.   const v: TD3DXVector2; const m: TD3DXMatrix): PD3DXVector2; stdcall; external d3dx8dll;
  395. {$EXTERNALSYM D3DXVec2TransformNormal}
  396.  
  397.  
  398. //--------------------------
  399. // 3D Vector
  400. //--------------------------
  401.  
  402. // inline
  403.  
  404. function D3DXVec3Length(const v: TD3DXVector3): Single;
  405. {$EXTERNALSYM D3DXVec3Length}
  406.  
  407. function D3DXVec3LengthSq(const v: TD3DXVector3): Single;
  408. {$EXTERNALSYM D3DXVec3LengthSq}
  409.  
  410. function D3DXVec3Dot(const v1, v2: TD3DXVector3): Single;
  411. {$EXTERNALSYM D3DXVec3Dot}
  412.  
  413. function D3DXVec3Cross(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  414. {$EXTERNALSYM D3DXVec3Cross}
  415.  
  416. function D3DXVec3Add(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  417. {$EXTERNALSYM D3DXVec3Add}
  418.  
  419. function D3DXVec3Subtract(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  420. {$EXTERNALSYM D3DXVec3Subtract}
  421.  
  422. // Minimize each component.  x = min(x1, x2), y = min(y1, y2), ...
  423. function D3DXVec3Minimize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  424. {$EXTERNALSYM D3DXVec3Minimize}
  425.  
  426. // Maximize each component.  x = max(x1, x2), y = max(y1, y2), ...
  427. function D3DXVec3Maximize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  428. {$EXTERNALSYM D3DXVec3Maximize}
  429.  
  430. function D3DXVec3Scale(out vOut: TD3DXVector3; const v: TD3DXVector3; s: Single): PD3DXVector3;
  431. {$EXTERNALSYM D3DXVec3Scale}
  432.  
  433. // Linear interpolation. V1 + s(V2-V1)
  434. function D3DXVec3Lerp(out vOut: TD3DXVector3;
  435.   const v1, v2: TD3DXVector3; s: Single): PD3DXVector3;
  436. {$EXTERNALSYM D3DXVec3Lerp}
  437.  
  438. // non-inline
  439.  
  440. function D3DXVec3Normalize(out vOut: TD3DXVector3;
  441.    const v: TD3DXVector3): PD3DXVector3; stdcall; external d3dx8dll;
  442. {$EXTERNALSYM D3DXVec3Normalize}
  443.  
  444. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  445. // and position V2, tangent T2 (when s == 1).
  446. function D3DXVec3Hermite(out vOut: TD3DXVector3;
  447.    const v1, t1, v2, t2: TD3DXVector3; s: Single): PD3DXVector3; stdcall; external d3dx8dll;
  448. {$EXTERNALSYM D3DXVec3Hermite}
  449.  
  450. // CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
  451. function D3DXVec3CatmullRom(out vOut: TD3DXVector3;
  452.    const v1, v2, v3: TD3DXVector3; s: Single): PD3DXVector3; stdcall; external d3dx8dll;
  453. {$EXTERNALSYM D3DXVec3CatmullRom}
  454.  
  455. // Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
  456. function D3DXVec3BaryCentric(out vOut: TD3DXVector3;
  457.    const v1, v2, v3: TD3DXVector3; f, g: Single): PD3DXVector3; stdcall; external d3dx8dll;
  458. {$EXTERNALSYM D3DXVec3BaryCentric}
  459.  
  460. // Transform (x, y, z, 1) by matrix.
  461. function D3DXVec3Transform(out vOut: TD3DXVector4;
  462.   const v: TD3DXVector3; const m: TD3DXMatrix): PD3DXVector4; stdcall; external d3dx8dll;
  463. {$EXTERNALSYM D3DXVec3Transform}
  464.  
  465. // Transform (x, y, z, 1) by matrix, project result back into w=1.
  466. function D3DXVec3TransformCoord(out vOut: TD3DXVector3;
  467.   const v: TD3DXVector3; const m: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx8dll;
  468. {$EXTERNALSYM D3DXVec3TransformCoord}
  469.  
  470. // Transform (x, y, z, 0) by matrix.  If you transforming a normal by a
  471. // non-affine matrix, the matrix you pass to this function should be the
  472. // transpose of the inverse of the matrix you would use to transform a coord.
  473. function D3DXVec3TransformNormal(out vOut: TD3DXVector3;
  474.   const v: TD3DXVector3; const m: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx8dll;
  475. {$EXTERNALSYM D3DXVec3TransformNormal}
  476.  
  477. // Project vector from object space into screen space
  478. function D3DXVec3Project(out vOut: TD3DXVector3;
  479.   const v: TD3DXVector3; const pViewport: TD3DViewport8;
  480.   const pProjection, pView, pWorld: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx8dll;
  481. {$EXTERNALSYM D3DXVec3Project}
  482.  
  483. // Project vector from screen space into object space
  484. function D3DXVec3Unproject(out vOut: TD3DXVector3;
  485.   const v: TD3DXVector3; const pViewport: TD3DViewport8;
  486.   const pProjection, pView, pWorld: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx8dll;
  487. {$EXTERNALSYM D3DXVec3Unproject}
  488.  
  489.  
  490. //--------------------------
  491. // 4D Vector
  492. //--------------------------
  493.  
  494. // inline
  495.  
  496. function D3DXVec4Length(const v: TD3DXVector4): Single;
  497. {$EXTERNALSYM D3DXVec4Length}
  498.  
  499. function D3DXVec4LengthSq(const v: TD3DXVector4): Single;
  500. {$EXTERNALSYM D3DXVec4LengthSq}
  501.  
  502. function D3DXVec4Dot(const v1, v2: TD3DXVector4): Single;
  503. {$EXTERNALSYM D3DXVec4Dot}
  504.  
  505. function D3DXVec4Add(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  506. {$EXTERNALSYM D3DXVec4Add}
  507.  
  508. function D3DXVec4Subtract(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  509. {$EXTERNALSYM D3DXVec4Subtract}
  510.  
  511. // Minimize each component.  x = min(x1, x2), y = min(y1, y2), ...
  512. function D3DXVec4Minimize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  513. {$EXTERNALSYM D3DXVec4Minimize}
  514.  
  515. // Maximize each component.  x = max(x1, x2), y = max(y1, y2), ...
  516. function D3DXVec4Maximize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  517. {$EXTERNALSYM D3DXVec4Maximize}
  518.  
  519. function D3DXVec4Scale(out vOut: TD3DXVector4; const v: TD3DXVector4; s: Single): PD3DXVector4;
  520. {$EXTERNALSYM D3DXVec4Scale}
  521.  
  522. // Linear interpolation. V1 + s(V2-V1)
  523. function D3DXVec4Lerp(out vOut: TD3DXVector4;
  524.   const v1, v2: TD3DXVector4; s: Single): PD3DXVector4;
  525. {$EXTERNALSYM D3DXVec4Lerp}
  526.  
  527. // non-inline
  528.  
  529. // Cross-product in 4 dimensions.
  530. function D3DXVec4Cross(out vOut: TD3DXVector4;
  531.   const v1, v2, v3: TD3DXVector4): PD3DXVector4; stdcall; external d3dx8dll;
  532. {$EXTERNALSYM D3DXVec4Cross}
  533.  
  534. function D3DXVec4Normalize(out vOut: TD3DXVector4;
  535.   const v: TD3DXVector4): PD3DXVector4; stdcall; external d3dx8dll;
  536. {$EXTERNALSYM D3DXVec4Normalize}
  537.  
  538. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  539. // and position V2, tangent T2 (when s == 1).
  540. function D3DXVec4Hermite(out vOut: TD3DXVector4;
  541.    const v1, t1, v2, t2: TD3DXVector4; s: Single): PD3DXVector4; stdcall; external d3dx8dll;
  542. {$EXTERNALSYM D3DXVec4Hermite}
  543.  
  544. // CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
  545. function D3DXVec4CatmullRom(out vOut: TD3DXVector4;
  546.    const v0, v1, v2, v3: TD3DXVector4; s: Single): PD3DXVector4; stdcall; external d3dx8dll;
  547. {$EXTERNALSYM D3DXVec4CatmullRom}
  548.  
  549. // Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
  550. function D3DXVec4BaryCentric(out vOut: TD3DXVector4;
  551.    const v1, v2, v3: TD3DXVector4; f, g: Single): PD3DXVector4; stdcall; external d3dx8dll;
  552. {$EXTERNALSYM D3DXVec4BaryCentric}
  553.  
  554. // Transform vector by matrix.
  555. function D3DXVec4Transform(out vOut: TD3DXVector4;
  556.   const v: TD3DXVector4; const m: TD3DXMatrix): PD3DXVector4; stdcall; external d3dx8dll;
  557. {$EXTERNALSYM D3DXVec4Transform}
  558.  
  559.  
  560. //--------------------------
  561. // 4D Matrix
  562. //--------------------------
  563.  
  564. // inline
  565.  
  566. function D3DXMatrixIdentity(out mOut: TD3DXMatrix): PD3DXMatrix;
  567. {$EXTERNALSYM D3DXMatrixIdentity}
  568.  
  569. function D3DXMatrixIsIdentity(const m: TD3DXMatrix): BOOL;
  570. {$EXTERNALSYM D3DXMatrixIsIdentity}
  571.  
  572. // non-inline
  573.  
  574. function D3DXMatrixfDeterminant(const m: TD3DXMatrix): Single; stdcall; external d3dx8dll;
  575. {$EXTERNALSYM D3DXMatrixfDeterminant}
  576.  
  577. function D3DXMatrixTranspose(out pOut: TD3DXMatrix; const pM: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx8dll;
  578. {$EXTERNALSYM D3DXMatrixTranspose}
  579.  
  580. // Matrix multiplication.  The result represents the transformation M2
  581. // followed by the transformation M1.  (Out = M1 * M2)
  582. function D3DXMatrixMultiply(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx8dll;
  583. {$EXTERNALSYM D3DXMatrixMultiply}
  584.  
  585. // Matrix multiplication, followed by a transpose. (Out = T(M1 * M2))
  586. function D3DXMatrixMultiplyTranspose(out pOut: TD3DXMatrix; const pM1, pM2: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx8dll;
  587. {$EXTERNALSYM D3DXMatrixMultiplyTranspose}
  588.  
  589. // Calculate inverse of matrix.  Inversion my fail, in which case NULL will
  590. // be returned.  The determinant of pM is also returned it pfDeterminant
  591. // is non-NULL.
  592. function D3DXMatrixInverse(out mOut: TD3DXMatrix; pfDeterminant: PSingle;
  593.     const m: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx8dll;
  594. {$EXTERNALSYM D3DXMatrixInverse}
  595.  
  596. // Build a matrix which scales by (sx, sy, sz)
  597. function D3DXMatrixScaling(out mOut: TD3DXMatrix; sx, sy, sz: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  598. {$EXTERNALSYM D3DXMatrixScaling}
  599.  
  600. // Build a matrix which translates by (x, y, z)
  601. function D3DXMatrixTranslation(out mOut: TD3DXMatrix; x, y, z: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  602. {$EXTERNALSYM D3DXMatrixTranslation}
  603.  
  604. // Build a matrix which rotates around the X axis
  605. function D3DXMatrixRotationX(out mOut: TD3DXMatrix; angle: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  606. {$EXTERNALSYM D3DXMatrixRotationX}
  607.  
  608. // Build a matrix which rotates around the Y axis
  609. function D3DXMatrixRotationY(out mOut: TD3DXMatrix; angle: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  610. {$EXTERNALSYM D3DXMatrixRotationY}
  611.  
  612. // Build a matrix which rotates around the Z axis
  613. function D3DXMatrixRotationZ(out mOut: TD3DXMatrix; angle: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  614. {$EXTERNALSYM D3DXMatrixRotationZ}
  615.  
  616. // Build a matrix which rotates around an arbitrary axis
  617. function D3DXMatrixRotationAxis(out mOut: TD3DXMatrix; const v: TD3DXVector3;
  618.   angle: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  619. {$EXTERNALSYM D3DXMatrixRotationAxis}
  620.  
  621. // Build a matrix from a quaternion
  622. function D3DXMatrixRotationQuaternion(out mOut: TD3DXMatrix; const Q: TD3DXQuaternion): PD3DXMatrix; stdcall; external d3dx8dll;
  623. {$EXTERNALSYM D3DXMatrixRotationQuaternion}
  624.  
  625. // Yaw around the Y axis, a pitch around the X axis,
  626. // and a roll around the Z axis.
  627. function D3DXMatrixRotationYawPitchRoll(out mOut: TD3DXMatrix; yaw, pitch, roll: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  628. {$EXTERNALSYM D3DXMatrixRotationYawPitchRoll}
  629.  
  630.  
  631. // Build transformation matrix.  NULL arguments are treated as identity.
  632. // Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt
  633. function D3DXMatrixTransformation(out mOut: TD3DXMatrix;
  634.    pScalingCenter: PD3DXVector3;
  635.    pScalingRotation: PD3DXQuaternion; pScaling, pRotationCenter: PD3DXVector3;
  636.    pRotation: PD3DXQuaternion; pTranslation: PD3DXVector3): PD3DXMatrix; stdcall; external d3dx8dll;
  637. {$EXTERNALSYM D3DXMatrixTransformation}
  638.  
  639. // Build affine transformation matrix.  NULL arguments are treated as identity.
  640. // Mout = Ms * Mrc-1 * Mr * Mrc * Mt
  641. function D3DXMatrixAffineTransformation(out mOut: TD3DXMatrix;
  642.    Scaling: Single; pRotationCenter: PD3DXVector3;
  643.    pRotation: PD3DXQuaternion; pTranslation: PD3DXVector3): PD3DXMatrix; stdcall; external d3dx8dll;
  644. {$EXTERNALSYM D3DXMatrixAffineTransformation}
  645.  
  646. // Build a lookat matrix. (right-handed)
  647. function D3DXMatrixLookAtRH(out mOut: TD3DXMatrix; const Eye, At, Up: TD3DXVector3): PD3DXMatrix; stdcall; external d3dx8dll;
  648. {$EXTERNALSYM D3DXMatrixLookAtRH}
  649.  
  650. // Build a lookat matrix. (left-handed)
  651. function D3DXMatrixLookAtLH(out mOut: TD3DXMatrix; const Eye, At, Up: TD3DXVector3): PD3DXMatrix; stdcall; external d3dx8dll;
  652. {$EXTERNALSYM D3DXMatrixLookAtLH}
  653.  
  654. // Build a perspective projection matrix. (right-handed)
  655. function D3DXMatrixPerspectiveRH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  656. {$EXTERNALSYM D3DXMatrixPerspectiveRH}
  657.  
  658. // Build a perspective projection matrix. (left-handed)
  659. function D3DXMatrixPerspectiveLH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  660. {$EXTERNALSYM D3DXMatrixPerspectiveLH}
  661.  
  662. // Build a perspective projection matrix. (right-handed)
  663. function D3DXMatrixPerspectiveFovRH(out mOut: TD3DXMatrix; flovy, aspect, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  664. {$EXTERNALSYM D3DXMatrixPerspectiveFovRH}
  665.  
  666. // Build a perspective projection matrix. (left-handed)
  667. function D3DXMatrixPerspectiveFovLH(out mOut: TD3DXMatrix; flovy, aspect, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  668. {$EXTERNALSYM D3DXMatrixPerspectiveFovLH}
  669.  
  670. // Build a perspective projection matrix. (right-handed)
  671. function D3DXMatrixPerspectiveOffCenterRH(out mOut: TD3DXMatrix;
  672.    l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  673. {$EXTERNALSYM D3DXMatrixPerspectiveOffCenterRH}
  674.  
  675. // Build a perspective projection matrix. (left-handed)
  676. function D3DXMatrixPerspectiveOffCenterLH(out mOut: TD3DXMatrix;
  677.    l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  678. {$EXTERNALSYM D3DXMatrixPerspectiveOffCenterLH}
  679.  
  680. // Build an ortho projection matrix. (right-handed)
  681. function D3DXMatrixOrthoRH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  682. {$EXTERNALSYM D3DXMatrixOrthoRH}
  683.  
  684. // Build an ortho projection matrix. (left-handed)
  685. function D3DXMatrixOrthoLH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  686. {$EXTERNALSYM D3DXMatrixOrthoLH}
  687.  
  688. // Build an ortho projection matrix. (right-handed)
  689. function D3DXMatrixOrthoOffCenterRH(out mOut: TD3DXMatrix;
  690.   l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  691. {$EXTERNALSYM D3DXMatrixOrthoOffCenterRH}
  692.  
  693. // Build an ortho projection matrix. (left-handed)
  694. function D3DXMatrixOrthoOffCenterLH(out mOut: TD3DXMatrix;
  695.   l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx8dll;
  696. {$EXTERNALSYM D3DXMatrixOrthoOffCenterLH}
  697.  
  698. // Build a matrix which flattens geometry into a plane, as if casting
  699. // a shadow from a light.
  700. function D3DXMatrixShadow(out mOut: TD3DXMatrix;
  701.   const Light: TD3DXVector4; const Plane: TD3DXPlane): PD3DXMatrix; stdcall; external d3dx8dll;
  702. {$EXTERNALSYM D3DXMatrixShadow}
  703.  
  704. // Build a matrix which reflects the coordinate system about a plane
  705. function D3DXMatrixReflect(out mOut: TD3DXMatrix;
  706.    const Plane: TD3DXPlane): PD3DXMatrix; stdcall; external d3dx8dll;
  707. {$EXTERNALSYM D3DXMatrixReflect}
  708.  
  709.  
  710. //--------------------------
  711. // Quaternion
  712. //--------------------------
  713.  
  714. // inline
  715.  
  716. function D3DXQuaternionLength(const q: TD3DXQuaternion): Single;
  717. {$EXTERNALSYM D3DXQuaternionLength}
  718.  
  719. // Length squared, or "norm"
  720. function D3DXQuaternionLengthSq(const q: TD3DXQuaternion): Single;
  721. {$EXTERNALSYM D3DXQuaternionLengthSq}
  722.  
  723. function D3DXQuaternionDot(const q1, q2: TD3DXQuaternion): Single;
  724. {$EXTERNALSYM D3DXQuaternionDot}
  725.  
  726. // (0, 0, 0, 1)
  727. function D3DXQuaternionIdentity(out qOut: TD3DXQuaternion): PD3DXQuaternion;
  728. {$EXTERNALSYM D3DXQuaternionIdentity}
  729.  
  730. function D3DXQuaternionIsIdentity (const q: TD3DXQuaternion): BOOL;
  731. {$EXTERNALSYM D3DXQuaternionIsIdentity}
  732.  
  733. // (-x, -y, -z, w)
  734. function D3DXQuaternionConjugate(out qOut: TD3DXQuaternion;
  735.   const q: TD3DXQuaternion): PD3DXQuaternion;
  736. {$EXTERNALSYM D3DXQuaternionConjugate}
  737.  
  738.  
  739. // non-inline
  740.  
  741. // Compute a quaternin's axis and angle of rotation. Expects unit quaternions.
  742. procedure D3DXQuaternionToAxisAngle(const q: TD3DXQuaternion;
  743.   out Axis: TD3DXVector3; out Angle: Single); stdcall; external d3dx8dll;
  744. {$EXTERNALSYM D3DXQuaternionToAxisAngle}
  745.  
  746. // Build a quaternion from a rotation matrix.
  747. function D3DXQuaternionRotationMatrix(out qOut: TD3DXQuaternion;
  748.   const m: TD3DXMatrix): PD3DXQuaternion; stdcall; external d3dx8dll;
  749. {$EXTERNALSYM D3DXQuaternionRotationMatrix}
  750.  
  751. // Rotation about arbitrary axis.
  752. function D3DXQuaternionRotationAxis(out qOut: TD3DXQuaternion;
  753.   const v: TD3DXVector3; Angle: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  754. {$EXTERNALSYM D3DXQuaternionRotationAxis}
  755.  
  756. // Yaw around the Y axis, a pitch around the X axis,
  757. // and a roll around the Z axis.
  758. function D3DXQuaternionRotationYawPitchRoll(out qOut: TD3DXQuaternion;
  759.   yaw, pitch, roll: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  760. {$EXTERNALSYM D3DXQuaternionRotationYawPitchRoll}
  761.  
  762. // Quaternion multiplication.  The result represents the rotation Q2
  763. // followed by the rotation Q1.  (Out = Q2 * Q1)
  764. function D3DXQuaternionMultiply(out qOut: TD3DXQuaternion;
  765.    const q1, q2: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  766. {$EXTERNALSYM D3DXQuaternionMultiply}
  767.  
  768. function D3DXQuaternionNormalize(out qOut: TD3DXQuaternion;
  769.    const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  770. {$EXTERNALSYM D3DXQuaternionNormalize}
  771.  
  772. // Conjugate and re-norm
  773. function D3DXQuaternionInverse(out qOut: TD3DXQuaternion;
  774.    const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  775. {$EXTERNALSYM D3DXQuaternionInverse}
  776.  
  777. // Expects unit quaternions.
  778. // if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v)
  779. function D3DXQuaternionLn(out qOut: TD3DXQuaternion;
  780.    const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  781. {$EXTERNALSYM D3DXQuaternionLn}
  782.  
  783. // Expects pure quaternions. (w == 0)  w is ignored in calculation.
  784. // if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v)
  785. function D3DXQuaternionExp(out qOut: TD3DXQuaternion;
  786.    const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx8dll;
  787. {$EXTERNALSYM D3DXQuaternionExp}
  788.  
  789. // Spherical linear interpolation between Q1 (s == 0) and Q2 (s == 1).
  790. // Expects unit quaternions.
  791. function D3DXQuaternionSlerp(out qOut: TD3DXQuaternion;
  792.    const q1, q2: TD3DXQuaternion; t: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  793. {$EXTERNALSYM D3DXQuaternionSlerp}
  794.  
  795. // Spherical quadrangle interpolation.
  796. // Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t))
  797. function D3DXQuaternionSquad(out qOut: TD3DXQuaternion;
  798.    const pQ1, pA, pB, pC: TD3DXQuaternion; t: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  799. {$EXTERNALSYM D3DXQuaternionSquad}
  800.  
  801. // Setup control points for spherical quadrangle interpolation
  802. // from Q1 to Q2.  The control points are chosen in such a way
  803. // to ensure the continuity of tangents with adjacent segments.
  804. procedure D3DXQuaternionSquadSetup(out pAOut, pBOut, pCOut: TD3DXQuaternion;
  805.    const pQ0, pQ1, pQ2, pQ3: TD3DXQuaternion); stdcall; external d3dx8dll;
  806. {$EXTERNALSYM D3DXQuaternionSquadSetup}
  807.  
  808. // Barycentric interpolation.
  809. // Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g))
  810. function D3DXQuaternionBaryCentric(out qOut: TD3DXQuaternion;
  811.    const q1, q2, q3: TD3DXQuaternion; f, g: Single): PD3DXQuaternion; stdcall; external d3dx8dll;
  812. {$EXTERNALSYM D3DXQuaternionBaryCentric}
  813.  
  814.  
  815. //--------------------------
  816. // Plane
  817. //--------------------------
  818.  
  819. // inline
  820.  
  821. // ax + by + cz + dw
  822. function D3DXPlaneDot(const p: TD3DXPlane; const v: TD3DXVector4): Single;
  823. {$EXTERNALSYM D3DXPlaneDot}
  824.  
  825. // ax + by + cz + d
  826. function D3DXPlaneDotCoord(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  827. {$EXTERNALSYM D3DXPlaneDotCoord}
  828.  
  829. // ax + by + cz
  830. function D3DXPlaneDotNormal(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  831. {$EXTERNALSYM D3DXPlaneDotNormal}
  832.  
  833.  
  834. // non-inline
  835.  
  836. // Normalize plane (so that |a,b,c| == 1)
  837. function D3DXPlaneNormalize(out pOut: TD3DXPlane; const p: TD3DXPlane): PD3DXPlane; stdcall; external d3dx8dll;
  838. {$EXTERNALSYM D3DXPlaneNormalize}
  839.  
  840. // Find the intersection between a plane and a line.  If the line is
  841. // parallel to the plane, NULL is returned.
  842. function D3DXPlaneIntersectLine(out vOut: TD3DXVector3;
  843.    const p: TD3DXPlane; const v1, v2: TD3DXVector3): PD3DXVector3; stdcall; external d3dx8dll;
  844. {$EXTERNALSYM D3DXPlaneIntersectLine}
  845.  
  846. // Construct a plane from a point and a normal
  847. function D3DXPlaneFromPointNormal(out pOut: TD3DXPlane;
  848.    const vPoint, vNormal: TD3DXVector3): PD3DXPlane; stdcall; external d3dx8dll;
  849. {$EXTERNALSYM D3DXPlaneFromPointNormal}
  850.  
  851. // Construct a plane from 3 points
  852. function D3DXPlaneFromPoints(out pOut: TD3DXPlane;
  853.    const v1, v2, v3: TD3DXVector3): PD3DXPlane; stdcall; external d3dx8dll;
  854. {$EXTERNALSYM D3DXPlaneFromPoints}
  855.  
  856. // Transform a plane by a matrix.  The vector (a,b,c) must be normal.
  857. // M should be the inverse transpose of the transformation desired.
  858. function D3DXPlaneTransform(out pOut: TD3DXPlane; const m: TD3DXMatrix): PD3DXPlane; stdcall; external d3dx8dll;
  859. {$EXTERNALSYM D3DXPlaneTransform}
  860.  
  861.  
  862. //--------------------------
  863. // Color
  864. //--------------------------
  865.  
  866. // inline
  867.  
  868. // (1-r, 1-g, 1-b, a)
  869. function D3DXColorNegative(out cOut: TD3DXColor; const c: TD3DXColor): PD3DXColor;
  870. {$EXTERNALSYM D3DXColorNegative}
  871.  
  872. function D3DXColorAdd(out cOut: TD3DXColor; const c1, c2: TD3DXColor): PD3DXColor;
  873. {$EXTERNALSYM D3DXColorAdd}
  874.  
  875. function D3DXColorSubtract(out cOut: TD3DXColor; const c1, c2: TD3DXColor): PD3DXColor;
  876. {$EXTERNALSYM D3DXColorSubtract}
  877.  
  878. function D3DXColorScale(out cOut: TD3DXColor; const c: TD3DXColor; s: Single): PD3DXColor;
  879. {$EXTERNALSYM D3DXColorScale}
  880.  
  881. // (r1*r2, g1*g2, b1*b2, a1*a2)
  882. function D3DXColorModulate(out cOut: TD3DXColor; const c1, c2: TD3DXColor): PD3DXColor;
  883. {$EXTERNALSYM D3DXColorModulate}
  884.  
  885. // Linear interpolation of r,g,b, and a. C1 + s(C2-C1)
  886. function D3DXColorLerp(out cOut: TD3DXColor; const c1, c2: TD3DXColor; s: Single): PD3DXColor;
  887. {$EXTERNALSYM D3DXColorLerp}
  888.  
  889. // non-inline
  890.  
  891. // Interpolate r,g,b between desaturated color and color.
  892. // DesaturatedColor + s(Color - DesaturatedColor)
  893. function D3DXColorAdjustSaturation(out cOut: TD3DXColor;
  894.    const pC: TD3DXColor; s: Single): PD3DXColor; stdcall; external d3dx8dll;
  895. {$EXTERNALSYM D3DXColorAdjustSaturation}
  896.  
  897. // Interpolate r,g,b between 50% grey and color.  Grey + s(Color - Grey)
  898. function D3DXColorAdjustContrast(out cOut: TD3DXColor;
  899.    const pC: TD3DXColor; c: Single): PD3DXColor; stdcall; external d3dx8dll;
  900. {$EXTERNALSYM D3DXColorAdjustContrast}
  901.  
  902.  
  903. //--------------------------
  904. // Misc
  905. //--------------------------
  906.  
  907. // Calculate Fresnel term given the cosine of theta (likely obtained by
  908. // taking the dot of two normals), and the refraction index of the material.
  909. function D3DXFresnelTerm(CosTheta, RefractionIndex: Single): Single; stdcall; external d3dx8dll;
  910. {$EXTERNALSYM D3DXFresnelTerm}
  911.  
  912.  
  913.  
  914. //===========================================================================
  915. //
  916. //    Matrix Stack
  917. //
  918. //===========================================================================
  919.  
  920. type
  921.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXMatrixStack);'}
  922.   {$EXTERNALSYM ID3DXMatrixStack}
  923.   ID3DXMatrixStack = interface(IUnknown)
  924.     ['{E3357330-CC5E-11d2-A434-00A0C90629A8}']
  925.     //
  926.     // ID3DXMatrixStack methods
  927.     //
  928.  
  929.     // Pops the top of the stack, returns the current top
  930.     // *after* popping the top.
  931.     function Pop: HResult; stdcall;
  932.  
  933.     // Pushes the stack by one, duplicating the current matrix.
  934.     function Push: HResult; stdcall;
  935.  
  936.     // Loads identity in the current matrix.
  937.     function LoadIdentity: HResult; stdcall;
  938.  
  939.     // Loads the given matrix into the current matrix
  940.     function LoadMatrix(const M: TD3DXMatrix): HResult; stdcall;
  941.  
  942.     // Right-Multiplies the given matrix to the current matrix.
  943.     // (transformation is about the current world origin)
  944.     function MultMatrix(const M: TD3DXMatrix): HResult; stdcall;
  945.  
  946.     // Left-Multiplies the given matrix to the current matrix
  947.     // (transformation is about the local origin of the object)
  948.     function MultMatrixLocal(const M: TD3DXMatrix): HResult; stdcall;
  949.  
  950.     // Right multiply the current matrix with the computed rotation
  951.     // matrix, counterclockwise about the given axis with the given angle.
  952.     // (rotation is about the current world origin)
  953.     function RotateAxis(const V: TD3DXVector3; Angle: Single): HResult; stdcall;
  954.  
  955.     // Left multiply the current matrix with the computed rotation
  956.     // matrix, counterclockwise about the given axis with the given angle.
  957.     // (rotation is about the local origin of the object)
  958.     function RotateAxisLocal(const V: TD3DXVector3; Angle: Single): HResult; stdcall;
  959.  
  960.     // Right multiply the current matrix with the computed rotation
  961.     // matrix. All angles are counterclockwise. (rotation is about the
  962.     // current world origin)
  963.  
  964.     // The rotation is composed of a yaw around the Y axis, a pitch around
  965.     // the X axis, and a roll around the Z axis.
  966.     function RotateYawPitchRoll(yaw, pitch, roll: Single): HResult; stdcall;
  967.  
  968.     // Left multiply the current matrix with the computed rotation
  969.     // matrix. All angles are counterclockwise. (rotation is about the
  970.     // local origin of the object)
  971.  
  972.     // The rotation is composed of a yaw around the Y axis, a pitch around
  973.     // the X axis, and a roll around the Z axis.
  974.     function RotateYawPitchRollLocal(yaw, pitch, roll: Single): HResult; stdcall;
  975.  
  976.     // Right multiply the current matrix with the computed scale
  977.     // matrix. (transformation is about the current world origin)
  978.     function Scale(x, y, z: Single): HResult; stdcall;
  979.  
  980.     // Left multiply the current matrix with the computed scale
  981.     // matrix. (transformation is about the local origin of the object)
  982.     function ScaleLocal(x, y, z: Single): HResult; stdcall;
  983.  
  984.     // Right multiply the current matrix with the computed translation
  985.     // matrix. (transformation is about the current world origin)
  986.     function Translate(x, y, z: Single): HResult; stdcall;
  987.  
  988.     // Left multiply the current matrix with the computed translation
  989.     // matrix. (transformation is about the local origin of the object)
  990.     function TranslateLocal(x, y, z: Single): HResult; stdcall;
  991.  
  992.     // Obtain the current matrix at the top of the stack
  993.     function GetTop: PD3DXMatrix; stdcall;
  994.   end;
  995.  
  996. type
  997.   IID_ID3DXMatrixStack = ID3DXMatrixStack;
  998.   {$EXTERNALSYM IID_ID3DXMatrixStack}
  999.  
  1000. function D3DXCreateMatrixStack(Flags: DWord; out Stack: ID3DXMatrixStack): HResult; stdcall; external d3dx8dll;
  1001. {$EXTERNALSYM D3DXCreateMatrixStack}
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009. ///////////////////////////////////////////////////////////////////////////
  1010. //
  1011. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  1012. //
  1013. //  File:       d3dx8core.h
  1014. //  Content:    D3DX core types and functions
  1015. //
  1016. ///////////////////////////////////////////////////////////////////////////
  1017.  
  1018. type
  1019. ///////////////////////////////////////////////////////////////////////////
  1020. // ID3DXBuffer:
  1021. // ------------
  1022. // The buffer object is used by D3DX to return arbitrary size data.
  1023. //
  1024. // GetBufferPointer -
  1025. //    Returns a pointer to the beginning of the buffer.
  1026. //
  1027. // GetBufferSize -
  1028. //    Returns the size of the buffer, in bytes.
  1029. ///////////////////////////////////////////////////////////////////////////
  1030.  
  1031.   PID3DXBuffer = ^ID3DXBuffer;
  1032.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXBuffer);'}
  1033.   {$EXTERNALSYM ID3DXBuffer}
  1034.   ID3DXBuffer = interface(IUnknown)
  1035.     ['{932E6A7E-C68E-45dd-A7BF-53D19C86DB1F}']
  1036.     // ID3DXBuffer
  1037.     function GetBufferPointer: Pointer; stdcall;
  1038.     function GetBufferSize: DWord; stdcall;
  1039.   end;
  1040.  
  1041.  
  1042.  
  1043. ///////////////////////////////////////////////////////////////////////////
  1044. // ID3DXFont:
  1045. // ----------
  1046. // Font objects contain the textures and resources needed to render
  1047. // a specific font on a specific device.
  1048. //
  1049. // Begin -
  1050. //    Prepartes device for drawing text.  This is optional.. if DrawText
  1051. //    is called outside of Begin/End, it will call Begin and End for you.
  1052. //
  1053. // DrawText -
  1054. //    Draws formatted text on a D3D device.  Some parameters are
  1055. //    surprisingly similar to those of GDI's DrawText function.  See GDI
  1056. //    documentation for a detailed description of these parameters.
  1057. //
  1058. // End -
  1059. //    Restores device state to how it was when Begin was called.
  1060. //
  1061. // OnLostDevice, OnResetDevice -
  1062. //    Call OnLostDevice() on this object before calling Reset() on the
  1063. //    device, so that this object can release any stateblocks and video
  1064. //    memory resources.  After Reset(), the call OnResetDevice().
  1065. //
  1066. ///////////////////////////////////////////////////////////////////////////
  1067.  
  1068.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXFont);'}
  1069.   {$EXTERNALSYM ID3DXFont}
  1070.   ID3DXFont = interface(IUnknown)
  1071.     ['{89FAD6A5-024D-49af-8FE7-F51123B85E25}']
  1072.     // ID3DXFont
  1073.     function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1074.     function GetLogFont(out pLogFont: TLogFont): HResult; stdcall;
  1075.  
  1076.     function _Begin: HResult; stdcall;
  1077.     function DrawTextA(pString: PAnsiChar; Count: Integer; const pRect: TRect; Format: DWord; Color: TD3DColor): Integer; stdcall;
  1078.     function DrawTextW(pString: PWideChar; Count: Integer; const pRect: TRect; Format: DWord; Color: TD3DColor): Integer; stdcall;
  1079.     function _End: HResult; stdcall;
  1080.  
  1081.     function OnLostDevice: HResult; stdcall;
  1082.     function OnResetDevice: HResult; stdcall;
  1083.   end;
  1084.  
  1085.  
  1086. function D3DXCreateFont(pDevice: IDirect3DDevice8; hFont: HFONT;
  1087.   out ppFont: ID3DXFont): HResult; stdcall; external d3dx8dll;
  1088. {$EXTERNALSYM D3DXCreateFont}
  1089.  
  1090. function D3DXCreateFontIndirect(pDevice: IDirect3DDevice8;
  1091.   const pLogFont: TLogFont; out ppFont: ID3DXFont): HResult; stdcall; external d3dx8dll;
  1092. {$EXTERNALSYM D3DXCreateFontIndirect}
  1093.  
  1094.  
  1095.  
  1096. ///////////////////////////////////////////////////////////////////////////
  1097. // ID3DXSprite:
  1098. // ------------
  1099. // This object intends to provide an easy way to drawing sprites using D3D.
  1100. //
  1101. // Begin -
  1102. //    Prepares device for drawing sprites
  1103. //
  1104. // Draw, DrawAffine, DrawTransform -
  1105. //    Draws a sprite in screen-space.  Before transformation, the sprite is
  1106. //    the size of SrcRect, with its top-left corner at the origin (0,0).
  1107. //    The color and alpha channels are modulated by Color.
  1108. //
  1109. // End -
  1110. //     Restores device state to how it was when Begin was called.
  1111. //
  1112. // OnLostDevice, OnResetDevice -
  1113. //    Call OnLostDevice() on this object before calling Reset() on the
  1114. //    device, so that this object can release any stateblocks and video
  1115. //    memory resources.  After Reset(), the call OnResetDevice().
  1116. ///////////////////////////////////////////////////////////////////////////
  1117. type
  1118.  
  1119.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXSprite);'}
  1120.   {$EXTERNALSYM ID3DXSprite}
  1121.   ID3DXSprite = interface(IUnknown)
  1122.     ['{13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7}']
  1123.     // ID3DXSprite
  1124.     function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1125.  
  1126.     function _Begin: HResult; stdcall;
  1127.  
  1128.     function Draw(pSrcTexture: IDirect3DTexture8; pSrcRect: PRect;
  1129.       pScaling, pRotationCenter: PD3DXVector2; Rotation: Single;
  1130.       pTranslation: PD3DXVector2; Color: TD3DColor): HResult; stdcall;
  1131.  
  1132.     function DrawTransform(pSrcTexture: IDirect3DTexture8; pSrcRect: PRect;
  1133.       const pTransform: TD3DXMatrix; Color: TD3DColor): HResult; stdcall;
  1134.  
  1135.     function _End: HResult; stdcall;
  1136.  
  1137.     function OnLostDevice: HResult; stdcall;
  1138.     function OnResetDevice: HResult; stdcall;
  1139.   end;
  1140.  
  1141.  
  1142. function D3DXCreateSprite(ppDevice: IDirect3DDevice8;
  1143.   out ppSprite: ID3DXSprite): HResult; stdcall; external d3dx8dll;
  1144. {$EXTERNALSYM D3DXCreateSprite}
  1145.  
  1146.  
  1147.  
  1148. ///////////////////////////////////////////////////////////////////////////
  1149. // ID3DXRenderToSurface:
  1150. // ---------------------
  1151. // This object abstracts rendering to surfaces.  These surfaces do not
  1152. // necessarily need to be render targets.  If they are not, a compatible
  1153. // render target is used, and the result copied into surface at end scene.
  1154. //
  1155. // BeginScene, EndScene -
  1156. //    Call BeginScene() and EndScene() at the beginning and ending of your
  1157. //    scene.  These calls will setup and restore render targets, viewports,
  1158. //    etc..
  1159. //
  1160. // OnLostDevice, OnResetDevice -
  1161. //    Call OnLostDevice() on this object before calling Reset() on the
  1162. //    device, so that this object can release any stateblocks and video
  1163. //    memory resources.  After Reset(), the call OnResetDevice().
  1164. ///////////////////////////////////////////////////////////////////////////
  1165. type
  1166.  
  1167.   PD3DXRTSDesc = ^TD3DXRTSDesc;
  1168.   _D3DXRTS_DESC = packed record
  1169.     Width: LongWord;
  1170.     Height: LongWord;
  1171.     Format: TD3DFormat;
  1172.     DepthStencil: BOOL;
  1173.     DepthStencilFormat: TD3DFormat;
  1174.   end {_D3DXRTS_DESC};
  1175.   {$EXTERNALSYM _D3DXRTS_DESC}
  1176.   D3DXRTS_DESC = _D3DXRTS_DESC;
  1177.   {$EXTERNALSYM D3DXRTS_DESC}
  1178.   TD3DXRTSDesc = _D3DXRTS_DESC;
  1179.  
  1180.  
  1181.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXRenderToSurface);'}
  1182.   {$EXTERNALSYM ID3DXRenderToSurface}
  1183.   ID3DXRenderToSurface = interface(IUnknown)
  1184.     ['{82DF5B90-E34E-496e-AC1C-62117A6A5913}']
  1185.     // ID3DXRenderToSurface
  1186.     function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1187.     function GetDesc(out pDesc: TD3DXRTSDesc): HResult; stdcall;
  1188.  
  1189.     function BeginScene(pSurface: IDirect3DSurface8; pViewport: PD3DViewport8): HResult; stdcall;
  1190.     function EndScene: HResult; stdcall;
  1191.  
  1192.     function OnLostDevice: HResult; stdcall;
  1193.     function OnResetDevice: HResult; stdcall;
  1194.   end;
  1195.  
  1196.  
  1197. function D3DXCreateRenderToSurface(ppDevice: IDirect3DDevice8;
  1198.   Width: LongWord;
  1199.   Height: LongWord;
  1200.   Format: TD3DFormat;
  1201.   DepthStencil: BOOL;
  1202.   DepthStencilFormat: TD3DFormat;
  1203.   out ppRenderToSurface: ID3DXRenderToSurface): HResult; stdcall; external d3dx8dll;
  1204. {$EXTERNALSYM D3DXCreateRenderToSurface}
  1205.  
  1206.  
  1207.  
  1208. ///////////////////////////////////////////////////////////////////////////
  1209. // ID3DXRenderToEnvMap:
  1210. // --------------------
  1211. // This object abstracts rendering to environment maps.  These surfaces
  1212. // do not necessarily need to be render targets.  If they are not, a
  1213. // compatible render target is used, and the result copied into the
  1214. // environment map at end scene.
  1215. //
  1216. // BeginCube, BeginSphere, BeginHemisphere, BeginParabolic -
  1217. //    This function initiates the rendering of the environment map.  As
  1218. //    parameters, you pass the textures in which will get filled in with
  1219. //    the resulting environment map.
  1220. //
  1221. // Face -
  1222. //    Call this function to initiate the drawing of each face.  For each
  1223. //    environment map, you will call this six times.. once for each face
  1224. //    in D3DCUBEMAP_FACES.
  1225. //
  1226. // End -
  1227. //    This will restore all render targets, and if needed compose all the
  1228. //    rendered faces into the environment map surfaces.
  1229. //
  1230. // OnLostDevice, OnResetDevice -
  1231. //    Call OnLostDevice() on this object before calling Reset() on the
  1232. //    device, so that this object can release any stateblocks and video
  1233. //    memory resources.  After Reset(), the call OnResetDevice().
  1234. ///////////////////////////////////////////////////////////////////////////
  1235. type
  1236.  
  1237.   PD3DXRTEDesc = ^TD3DXRTEDesc;
  1238.   _D3DXRTE_DESC = record
  1239.     Size: LongWord;
  1240.     Format: TD3DFormat;
  1241.     DepthStencil: Bool;
  1242.     DepthStencilFormat: TD3DFormat;
  1243.   end {_D3DXRTE_DESC};
  1244.   {$EXTERNALSYM _D3DXRTE_DESC}
  1245.   D3DXRTE_DESC = _D3DXRTE_DESC;
  1246.   {$EXTERNALSYM D3DXRTE_DESC}
  1247.   TD3DXRTEDesc = _D3DXRTE_DESC;
  1248.  
  1249.  
  1250.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXRenderToEnvMap);'}
  1251.   {$EXTERNALSYM ID3DXRenderToEnvMap}
  1252.   ID3DXRenderToEnvMap = interface(IUnknown)
  1253.     ['{4E42C623-9451-44b7-8C86-ABCCDE5D52C8}']
  1254.     // ID3DXRenderToEnvMap
  1255.     function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1256.     function GetDesc(out pDesc: TD3DXRTEDesc): HResult; stdcall;
  1257.  
  1258.     function BeginCube(pCubeTex: IDirect3DCubeTexture8): HResult; stdcall;
  1259.  
  1260.     function BeginSphere(pTex: IDirect3DTexture8): HResult; stdcall;
  1261.  
  1262.     function BeginHemisphere(pTexZPos, pTexZNeg: IDirect3DTexture8): HResult; stdcall;
  1263.  
  1264.     function BeginParabolic(pTexZPos, pTexZNeg: IDirect3DTexture8): HResult; stdcall;
  1265.  
  1266.     function Face(Face: TD3DCubemapFaces): HResult; stdcall;
  1267.     function _End: HResult; stdcall;
  1268.  
  1269.     function OnLostDevice: HResult; stdcall;
  1270.     function OnResetDevice: HResult; stdcall;
  1271.   end;
  1272.  
  1273.  
  1274. function D3DXCreateRenderToEnvMap(ppDevice: IDirect3DDevice8;
  1275.   Size: LongWord;
  1276.   Format: TD3DFormat;
  1277.   DepthStencil: BOOL;
  1278.   DepthStencilFormat: TD3DFormat;
  1279.   out ppRenderToEnvMap: ID3DXRenderToEnvMap): HResult; stdcall; external d3dx8dll;
  1280. {$EXTERNALSYM D3DXCreateRenderToEnvMap}
  1281.  
  1282.  
  1283.  
  1284. ///////////////////////////////////////////////////////////////////////////
  1285. // Shader assemblers:
  1286. ///////////////////////////////////////////////////////////////////////////
  1287.  
  1288. //-------------------------------------------------------------------------
  1289. // D3DXASM flags:
  1290. // --------------
  1291. //
  1292. // D3DXASM_DEBUG
  1293. //   Generate debug info.
  1294. //
  1295. // D3DXASM_SKIPVALIDATION
  1296. //   Do not validate the generated code against known capabilities and
  1297. //   constraints.  This option is only recommended when assembling shaders
  1298. //   you KNOW will work.  (ie. have assembled before without this option.)
  1299. //-------------------------------------------------------------------------
  1300. const
  1301.   D3DXASM_DEBUG           = (1 shl 0);
  1302.   {$EXTERNALSYM D3DXASM_DEBUG}
  1303.   D3DXASM_SKIPVALIDATION  = (1 shl 1);
  1304.   {$EXTERNALSYM D3DXASM_SKIPVALIDATION}
  1305.  
  1306.  
  1307. //-------------------------------------------------------------------------
  1308. // D3DXAssembleShader:
  1309. // -------------------
  1310. // Assembles an ascii description of a vertex or pixel shader into
  1311. // binary form.
  1312. //
  1313. // Parameters:
  1314. //  pSrcFile
  1315. //      Source file name
  1316. //  hSrcModule
  1317. //      Module handle. if NULL, current module will be used.
  1318. //  pSrcResource
  1319. //      Resource name in module
  1320. //  pSrcData
  1321. //      Pointer to source code
  1322. //  SrcDataLen
  1323. //      Size of source code, in bytes
  1324. //  Flags
  1325. //      D3DXASM_xxx flags
  1326. //  ppConstants
  1327. //      Returns an ID3DXBuffer object containing constant declarations.
  1328. //  ppCompiledShader
  1329. //      Returns an ID3DXBuffer object containing the object code.
  1330. //  ppCompilationErrors
  1331. //      Returns an ID3DXBuffer object containing ascii error messages
  1332. //-------------------------------------------------------------------------
  1333.  
  1334. function D3DXAssembleShaderFromFileA(
  1335.   pSrcFile: PAnsiChar;
  1336.   Flags: DWord;
  1337.   ppConstants: PID3DXBuffer;
  1338.   ppCompiledShader: PID3DXBuffer;
  1339.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromFileA';
  1340. {$EXTERNALSYM D3DXAssembleShaderFromFileA}
  1341.  
  1342. function D3DXAssembleShaderFromFileW(
  1343.   pSrcFile: PWideChar;
  1344.   Flags: DWord;
  1345.   ppConstants: PID3DXBuffer;
  1346.   ppCompiledShader: PID3DXBuffer;
  1347.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromFileW';
  1348. {$EXTERNALSYM D3DXAssembleShaderFromFileW}
  1349.  
  1350. function D3DXAssembleShaderFromFile(
  1351.   pSrcFile: PChar;
  1352.   Flags: DWord;
  1353.   ppConstants: PID3DXBuffer;
  1354.   ppCompiledShader: PID3DXBuffer;
  1355.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromFileA';
  1356. {$EXTERNALSYM D3DXAssembleShaderFromFile}
  1357.  
  1358.  
  1359. function D3DXAssembleShaderFromResourceA(
  1360.   hSrcModule: HModule;
  1361.   pSrcResource: PAnsiChar;
  1362.   Flags: DWord;
  1363.   ppConstants: PID3DXBuffer;
  1364.   ppCompiledShader: PID3DXBuffer;
  1365.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromResourceA';
  1366. {$EXTERNALSYM D3DXAssembleShaderFromResourceA}
  1367.  
  1368. function D3DXAssembleShaderFromResourceW(
  1369.   hSrcModule: HModule;
  1370.   pSrcResource: PWideChar;
  1371.   Flags: DWord;
  1372.   ppConstants: PID3DXBuffer;
  1373.   ppCompiledShader: PID3DXBuffer;
  1374.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromResourceW';
  1375. {$EXTERNALSYM D3DXAssembleShaderFromResourceW}
  1376.  
  1377. function D3DXAssembleShaderFromResource(
  1378.   hSrcModule: HModule;
  1379.   pSrcResource: PChar;
  1380.   Flags: DWord;
  1381.   ppConstants: PID3DXBuffer;
  1382.   ppCompiledShader: PID3DXBuffer;
  1383.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXAssembleShaderFromResourceA';
  1384. {$EXTERNALSYM D3DXAssembleShaderFromResource}
  1385.  
  1386.  
  1387. function D3DXAssembleShader(
  1388.   const pSrcData;
  1389.   SrcDataLen: LongWord;
  1390.   Flags: DWord;
  1391.   ppConstants: PID3DXBuffer;
  1392.   ppCompiledShader: PID3DXBuffer;
  1393.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1394. {$EXTERNALSYM D3DXAssembleShader}
  1395.  
  1396.  
  1397. ///////////////////////////////////////////////////////////////////////////
  1398. // Misc APIs:
  1399. ///////////////////////////////////////////////////////////////////////////
  1400.  
  1401.  
  1402. //-------------------------------------------------------------------------
  1403. // D3DXGetErrorString:
  1404. // ------------------
  1405. // Returns the error string for given an hresult.  Interprets all D3DX and
  1406. // D3D hresults.
  1407. //
  1408. // Parameters:
  1409. //  hr
  1410. //      The error code to be deciphered.
  1411. //  pBuffer
  1412. //      Pointer to the buffer to be filled in.
  1413. //  BufferLen
  1414. //      Count of characters in buffer.  Any error message longer than this
  1415. //      length will be truncated to fit.
  1416. //-------------------------------------------------------------------------
  1417. function D3DXGetErrorStringA(hr: HResult; pBuffer: PAnsiChar; BufferLen: LongWord): HResult; stdcall; external d3dx8dll name 'D3DXGetErrorStringA'; overload; 
  1418. {$EXTERNALSYM D3DXGetErrorStringA}
  1419. function D3DXGetErrorStringW(hr: HResult; pBuffer: PWideChar; BufferLen: LongWord): HResult; stdcall; external d3dx8dll name 'D3DXGetErrorStringW'; overload; 
  1420. {$EXTERNALSYM D3DXGetErrorStringW}
  1421. function D3DXGetErrorString(hr: HResult; pBuffer: PChar; BufferLen: LongWord): HResult; stdcall; external d3dx8dll name 'D3DXGetErrorStringA'; overload; 
  1422. {$EXTERNALSYM D3DXGetErrorString}
  1423.  
  1424. // Object Pascal support functions for D3DXGetErrorString
  1425. function D3DXGetErrorStringA(hr: HResult): String; overload;
  1426. function D3DXGetErrorStringW(hr: HResult): WideString; overload;
  1427. {$IFNDEF UNICODE}
  1428. function D3DXGetErrorString(hr: HResult): String; overload;
  1429. {$ELSE}
  1430. function D3DXGetErrorString(hr: HResult): WideString; overload;
  1431. {$ENDIF}
  1432.  
  1433.  
  1434.  
  1435. ///////////////////////////////////////////////////////////////////////////
  1436. //
  1437. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  1438. //
  1439. //  File:       d3dx8effect.h
  1440. //  Content:    D3DX effect types and functions
  1441. //
  1442. ///////////////////////////////////////////////////////////////////////////
  1443.  
  1444. const
  1445.   D3DXFX_DONOTSAVESTATE = (1 shl 0);
  1446.   {$EXTERNALSYM D3DXFX_DONOTSAVESTATE}
  1447.  
  1448. type
  1449.   _D3DXPARAMETERTYPE = (
  1450.     D3DXPT_DWORD        {= 0},
  1451.     D3DXPT_FLOAT        {= 1},
  1452.     D3DXPT_VECTOR       {= 2},
  1453.     D3DXPT_MATRIX       {= 3},
  1454.     D3DXPT_TEXTURE      {= 4},
  1455.     D3DXPT_VERTEXSHADER {= 5},
  1456.     D3DXPT_PIXELSHADER  {= 6},
  1457.     D3DXPT_CONSTANT     {= 7},
  1458.     D3DXPT_STRING       {= 8}
  1459.   ); {_D3DXPARAMETERTYPE}
  1460.   {$EXTERNALSYM _D3DXPARAMETERTYPE}
  1461.   D3DXPARAMETERTYPE = _D3DXPARAMETERTYPE;
  1462.   {$EXTERNALSYM D3DXPARAMETERTYPE}
  1463.   TD3DXParameterType = _D3DXPARAMETERTYPE;
  1464.  
  1465. type
  1466.   PD3DXEffectDesc = ^TD3DXEffectDesc;
  1467.   _D3DXEFFECT_DESC = packed record
  1468.     Parameters: LongWord;
  1469.     Techniques: LongWord;
  1470.   end;
  1471.   {$EXTERNALSYM _D3DXEFFECT_DESC}
  1472.   D3DXEFFECT_DESC = _D3DXEFFECT_DESC;
  1473.   {$EXTERNALSYM D3DXEFFECT_DESC}
  1474.   TD3DXEffectDesc = _D3DXEFFECT_DESC;
  1475.  
  1476.  
  1477.   PD3DXParameterDesc = ^TD3DXParameterDesc;
  1478.   _D3DXPARAMETER_DESC = packed record
  1479.     Name:  PAnsiChar;
  1480.     Index: PAnsiChar;
  1481.     _Type: TD3DXParameterType;
  1482.   end;
  1483.   {$EXTERNALSYM _D3DXPARAMETER_DESC}
  1484.   D3DXPARAMETER_DESC = _D3DXPARAMETER_DESC;
  1485.   {$EXTERNALSYM D3DXPARAMETER_DESC}
  1486.   TD3DXParameterDesc = _D3DXPARAMETER_DESC;
  1487.  
  1488.  
  1489.   PD3DXTechniqueDesc = ^TD3DXTechniqueDesc;
  1490.   _D3DXTECHNIQUE_DESC = packed record
  1491.     Name:  PAnsiChar;
  1492.     Index: PAnsiChar;
  1493.     Passes: LongWord;
  1494.   end;
  1495.   {$EXTERNALSYM _D3DXTECHNIQUE_DESC}
  1496.   D3DXTECHNIQUE_DESC = _D3DXTECHNIQUE_DESC;
  1497.   {$EXTERNALSYM D3DXTECHNIQUE_DESC}
  1498.   TD3DXTechniqueDesc = _D3DXTECHNIQUE_DESC;
  1499.  
  1500.  
  1501.   PD3DXPassDesc = ^TD3DXPassDesc;
  1502.   _D3DXPASS_DESC = packed record
  1503.     Name:  PAnsiChar;
  1504.     Index: PAnsiChar;
  1505.   end;
  1506.   {$EXTERNALSYM _D3DXPASS_DESC}
  1507.   D3DXPASS_DESC = _D3DXPASS_DESC;
  1508.   {$EXTERNALSYM D3DXPASS_DESC}
  1509.   TD3DXPassDesc = _D3DXPASS_DESC;
  1510.  
  1511.  
  1512.  
  1513. //////////////////////////////////////////////////////////////////////////////
  1514. // ID3DXEffect ///////////////////////////////////////////////////////////////
  1515. //////////////////////////////////////////////////////////////////////////////
  1516.  
  1517.  
  1518.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXEffect);'}
  1519.   {$EXTERNALSYM ID3DXEffect}
  1520.   ID3DXEffect = interface(IUnknown)
  1521.     ['{648B1CEB-8D4E-4d66-B6FA-E44969E82E89}']
  1522.     // ID3DXEffect
  1523.     function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1524.     function GetDesc(out pDesc: TD3DXEffectDesc): HResult; stdcall;
  1525.     function GetParameterDesc(pParameter: PAnsiChar; out pDesc: TD3DXParameterDesc): HResult; stdcall;
  1526.     function GetTechniqueDesc(pTechnique: PAnsiChar; out pDesc: TD3DXTechniqueDesc): HResult; stdcall;
  1527.     function GetPassDesc(pTechnique, pPass: PAnsiChar; out pDesc: TD3DXPassDesc): HResult; stdcall;
  1528.     function FindNextValidTechnique(pTechnique: PAnsiChar; out pDesc: TD3DXTechniqueDesc): HResult; stdcall;
  1529.     function CloneEffect(pDevice: IDirect3DDevice8; out ppEffect: ID3DXEffect): HResult; stdcall;
  1530.     function GetCompiledEffect(out ppCompiledEffect: ID3DXBuffer): HResult; stdcall;
  1531.  
  1532.     function SetTechnique(pTechnique: PAnsiChar): HResult; stdcall;
  1533.     function GetTechnique(out ppTechnique: PAnsiChar): HResult; stdcall;
  1534.  
  1535.     function SetDword(pParameter: PAnsiChar; dw: DWord): HResult; stdcall;
  1536.     function GetDword(pParameter: PAnsiChar; out pdw: DWord): HResult; stdcall;
  1537.     function SetFloat(pParameter: PAnsiChar; f: Single): HResult; stdcall;
  1538.     function GetFloat(pParameter: PAnsiChar; out pf: Single): HResult; stdcall;
  1539.     function SetVector(pParameter: PAnsiChar; const pVector: TD3DXVector4): HResult; stdcall;
  1540.     function GetVector(pParameter: PAnsiChar; out pVector: TD3DXVector4): HResult; stdcall;
  1541.     function SetMatrix(pParameter: PAnsiChar; const pMatrix: TD3DXMatrix): HResult; stdcall;
  1542.     function GetMatrix(pParameter: PAnsiChar; out pMatrix: TD3DXMatrix): HResult; stdcall;
  1543.     function SetTexture(pParameter: PAnsiChar; pTexture: IDirect3DBaseTexture8): HResult; stdcall;
  1544.     function GetTexture(pParameter: PAnsiChar; out ppTexture: IDirect3DBaseTexture8): HResult; stdcall;
  1545.     function SetVertexShader(pParameter: PAnsiChar; Handle: DWord): HResult; stdcall;
  1546.     function GetVertexShader(pParameter: PAnsiChar; out Handle: DWord): HResult; stdcall;
  1547.     function SetPixelShader(pParameter: PAnsiChar; Handle: DWord): HResult; stdcall;
  1548.     function GetPixelShader(pParameter: PAnsiChar; out Handle: DWord): HResult; stdcall;
  1549.     function SetString(pParameter: PAnsiChar; pString: PAnsiChar): HResult; stdcall;
  1550.     function GetString(pParameter: PAnsiChar; out ppString: PAnsiChar): HResult; stdcall;
  1551.     function IsParameterUsed(pParameter: PAnsiChar): BOOL; stdcall;
  1552.  
  1553.     function Validate: HResult; stdcall;
  1554.     function _Begin(out pPasses: LongWord; Flags: DWord): HResult; stdcall;
  1555.     function Pass(Pass: LongWord): HResult; stdcall;
  1556.     function _End: HResult; stdcall;
  1557.     function OnLostDevice: HResult; stdcall;
  1558.     function OnResetDevice: HResult; stdcall;
  1559.   end;
  1560.  
  1561.  
  1562.  
  1563. //////////////////////////////////////////////////////////////////////////////
  1564. // APIs //////////////////////////////////////////////////////////////////////
  1565. //////////////////////////////////////////////////////////////////////////////
  1566.  
  1567.  
  1568.  
  1569. //----------------------------------------------------------------------------
  1570. // D3DXCreateEffect:
  1571. // -----------------
  1572. // Creates an effect from an ascii or binaray effect description.
  1573. //
  1574. // Parameters:
  1575. //  pDevice
  1576. //      Pointer of the device on which to create the effect
  1577. //  pSrcFile
  1578. //      Name of the file containing the effect description
  1579. //  hSrcModule
  1580. //      Module handle. if NULL, current module will be used.
  1581. //  pSrcResource
  1582. //      Resource name in module
  1583. //  pSrcData
  1584. //      Pointer to effect description
  1585. //  SrcDataSize
  1586. //      Size of the effect description in bytes
  1587. //  ppEffect
  1588. //      Returns a buffer containing created effect.
  1589. //  ppCompilationErrors
  1590. //      Returns a buffer containing any error messages which occurred during
  1591. //      compile.  Or NULL if you do not care about the error messages.
  1592. //
  1593. //----------------------------------------------------------------------------
  1594.  
  1595.  
  1596. function D3DXCreateEffectFromFileA(
  1597.   pDevice: IDirect3DDevice8;
  1598.   pSrcFile: PAnsiChar;
  1599.   out ppEffect: ID3DXEffect;
  1600.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromFileA';
  1601. {$EXTERNALSYM D3DXCreateEffectFromFileA}
  1602.  
  1603. function D3DXCreateEffectFromFileW(
  1604.   pDevice: IDirect3DDevice8;
  1605.   pSrcFile: PWideChar;
  1606.   out ppEffect: ID3DXEffect;
  1607.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromFileW';
  1608. {$EXTERNALSYM D3DXCreateEffectFromFileW}
  1609.  
  1610. function D3DXCreateEffectFromFile(
  1611.   pDevice: IDirect3DDevice8;
  1612.   pSrcFile: PChar;
  1613.   out ppEffect: ID3DXEffect;
  1614.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromFileA';
  1615. {$EXTERNALSYM D3DXCreateEffectFromFile}
  1616.  
  1617. function D3DXCreateEffectFromResourceA(
  1618.   pDevice: IDirect3DDevice8;
  1619.   hSrcModule: HModule;
  1620.   pSrcResource: PAnsiChar;
  1621.   out ppEffect: ID3DXEffect;
  1622.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromResourceA';
  1623. {$EXTERNALSYM D3DXCreateEffectFromResourceA}
  1624.  
  1625. function D3DXCreateEffectFromResourceW(
  1626.   pDevice: IDirect3DDevice8;
  1627.   hSrcModule: HModule;
  1628.   pSrcResource: PWideChar;
  1629.   out ppEffect: ID3DXEffect;
  1630.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromResourceW';
  1631. {$EXTERNALSYM D3DXCreateEffectFromResourceW}
  1632.  
  1633. function D3DXCreateEffectFromResource(
  1634.   pDevice: IDirect3DDevice8;
  1635.   hSrcModule: HModule;
  1636.   pSrcResource: PChar;
  1637.   out ppEffect: ID3DXEffect;
  1638.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll name 'D3DXCreateEffectFromResourceA';
  1639. {$EXTERNALSYM D3DXCreateEffectFromResource}
  1640.  
  1641.  
  1642. function D3DXCreateEffect(
  1643.   pDevice: IDirect3DDevice8;
  1644.   const pSrcData;
  1645.   SrcDataSize: LongWord;
  1646.   out ppEffect: ID3DXEffect;
  1647.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  1648. {$EXTERNALSYM D3DXCreateEffect}
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656. //////////////////////////////////////////////////////////////////////////////
  1657. //
  1658. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  1659. //
  1660. //  File:       d3dx8mesh.h
  1661. //  Content:    D3DX mesh types and functions
  1662. //
  1663. //////////////////////////////////////////////////////////////////////////////
  1664.  
  1665. type
  1666.   _D3DXMESH = {$IFDEF TYPE_IDENTITY}type {$ENDIF}DWord;
  1667.   {$EXTERNALSYM _D3DXMESH}
  1668.   TD3DXMesh = _D3DXMESH;
  1669.  
  1670. // Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags
  1671. const
  1672.   D3DXMESH_32BIT                  = $001; // If set, then use 32 bit indices, if not set use 16 bit indices.
  1673.   {$EXTERNALSYM D3DXMESH_32BIT}
  1674.   D3DXMESH_DONOTCLIP              = $002; // Use D3DUSAGE_DONOTCLIP for VB & IB.
  1675.   {$EXTERNALSYM D3DXMESH_DONOTCLIP}
  1676.   D3DXMESH_POINTS                 = $004; // Use D3DUSAGE_POINTS for VB & IB.
  1677.   {$EXTERNALSYM D3DXMESH_POINTS}
  1678.   D3DXMESH_RTPATCHES              = $008; // Use D3DUSAGE_RTPATCHES for VB & IB.
  1679.   {$EXTERNALSYM D3DXMESH_RTPATCHES}
  1680.   D3DXMESH_NPATCHES      = $4000;// Use D3DUSAGE_NPATCHES for VB & IB.
  1681.   {$EXTERNALSYM D3DXMESH_NPATCHES}
  1682.   D3DXMESH_VB_SYSTEMMEM      = $010; // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER
  1683.   {$EXTERNALSYM D3DXMESH_VB_SYSTEMMEM}
  1684.   D3DXMESH_VB_MANAGED             = $020; // Use D3DPOOL_MANAGED for VB.
  1685.   {$EXTERNALSYM D3DXMESH_VB_MANAGED}
  1686.   D3DXMESH_VB_WRITEONLY           = $040; // Use D3DUSAGE_WRITEONLY for VB.
  1687.   {$EXTERNALSYM D3DXMESH_VB_WRITEONLY}
  1688.   D3DXMESH_VB_DYNAMIC             = $080; // Use D3DUSAGE_DYNAMIC for VB.
  1689.   {$EXTERNALSYM D3DXMESH_VB_DYNAMIC}
  1690.   D3DXMESH_VB_SOFTWAREPROCESSING = $8000; // Use D3DUSAGE_SOFTWAREPROCESSING for VB.
  1691.   {$EXTERNALSYM D3DXMESH_VB_SOFTWAREPROCESSING}
  1692.   D3DXMESH_IB_SYSTEMMEM      = $100; // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER
  1693.   {$EXTERNALSYM D3DXMESH_IB_SYSTEMMEM}
  1694.   D3DXMESH_IB_MANAGED             = $200; // Use D3DPOOL_MANAGED for IB.
  1695.   {$EXTERNALSYM D3DXMESH_IB_MANAGED}
  1696.   D3DXMESH_IB_WRITEONLY           = $400; // Use D3DUSAGE_WRITEONLY for IB.
  1697.   {$EXTERNALSYM D3DXMESH_IB_WRITEONLY}
  1698.   D3DXMESH_IB_DYNAMIC             = $800; // Use D3DUSAGE_DYNAMIC for IB.
  1699.   {$EXTERNALSYM D3DXMESH_IB_DYNAMIC}
  1700.   D3DXMESH_IB_SOFTWAREPROCESSING= $10000; // Use D3DUSAGE_SOFTWAREPROCESSING for IB.
  1701.   {$EXTERNALSYM D3DXMESH_IB_SOFTWAREPROCESSING}
  1702.  
  1703.   D3DXMESH_VB_SHARE               = $1000; // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer
  1704.   {$EXTERNALSYM D3DXMESH_VB_SHARE}
  1705.  
  1706.   D3DXMESH_USEHWONLY              = $2000; // Valid for ID3DXSkinMesh::ConvertToBlendedMesh
  1707.   {$EXTERNALSYM D3DXMESH_USEHWONLY}
  1708.  
  1709.   // Helper options
  1710.   D3DXMESH_SYSTEMMEM      = $110; // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM
  1711.   {$EXTERNALSYM D3DXMESH_SYSTEMMEM}
  1712.   D3DXMESH_MANAGED                = $220; // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED
  1713.   {$EXTERNALSYM D3DXMESH_MANAGED}
  1714.   D3DXMESH_WRITEONLY              = $440; // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY
  1715.   {$EXTERNALSYM D3DXMESH_WRITEONLY}
  1716.   D3DXMESH_DYNAMIC                = $880; // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC
  1717.   {$EXTERNALSYM D3DXMESH_DYNAMIC}
  1718.   D3DXMESH_SOFTWAREPROCESSING   = $18000; // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING
  1719.   {$EXTERNALSYM D3DXMESH_SOFTWAREPROCESSING}
  1720.  
  1721. type
  1722.   // option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh
  1723.   _D3DXMESHSIMP = (
  1724.   {$IFNDEF COMPILER6_UP}
  1725.     D3DXMESHSIMP_INVALID_0{= 0x0},
  1726.     D3DXMESHSIMP_VERTEX   {= 0x1},
  1727.     D3DXMESHSIMP_FACE     {= 0x2}
  1728.   {$ELSE}
  1729.     D3DXMESHSIMP_VERTEX   = $1,
  1730.     D3DXMESHSIMP_FACE     = $2
  1731.   {$ENDIF}
  1732.   );
  1733.   {$EXTERNALSYM _D3DXMESHSIMP}
  1734.   TD3DMeshSimp = _D3DXMESHSIMP;
  1735.  
  1736.   _MAX_FVF_DECL_SIZE = DWord;
  1737.   {$EXTERNALSYM _MAX_FVF_DECL_SIZE}
  1738. const
  1739.   MAX_FVF_DECL_SIZE = 20;
  1740.   {$EXTERNALSYM MAX_FVF_DECL_SIZE}
  1741.  
  1742. type
  1743.   TFVFDeclaration = array [0..MAX_FVF_DECL_SIZE-1] of DWord;
  1744.  
  1745.   PD3DXAttributeRange = ^TD3DXAttributeRange;
  1746.   _D3DXATTRIBUTERANGE = packed record
  1747.     AttribId:    DWord;
  1748.     FaceStart:   DWord;
  1749.     FaceCount:   DWord;
  1750.     VertexStart: DWord;
  1751.     VertexCount: DWord;
  1752.   end;
  1753.   {$EXTERNALSYM _D3DXATTRIBUTERANGE}
  1754.   D3DXATTRIBUTERANGE = _D3DXATTRIBUTERANGE;
  1755.   {$EXTERNALSYM D3DXATTRIBUTERANGE}
  1756.   TD3DXAttributeRange = _D3DXATTRIBUTERANGE;
  1757.  
  1758.   PD3DXMaterial = ^TD3DXMaterial;
  1759.   D3DXMATERIAL = packed record
  1760.     MatD3D: TD3Dmaterial8;
  1761.     pTextureFilename: PAnsiChar;
  1762.   end;
  1763.   {$EXTERNALSYM D3DXMATERIAL}
  1764.   TD3DXMaterial = D3DXMATERIAL;
  1765.  
  1766.   PD3DXAttributeWeights = ^TD3DXAttributeWeights;
  1767.   _D3DXATTRIBUTEWEIGHTS = packed record
  1768.     Position: Single;
  1769.     Boundary: Single;
  1770.     Normal:   Single;
  1771.     Diffuse:  Single;
  1772.     Specular: Single;
  1773.     Tex: array[0..7] of Single;
  1774.   end;
  1775.   {$EXTERNALSYM _D3DXATTRIBUTEWEIGHTS}
  1776.   D3DXATTRIBUTEWEIGHTS = _D3DXATTRIBUTEWEIGHTS;
  1777.   {$EXTERNALSYM D3DXATTRIBUTEWEIGHTS}
  1778.   TD3DXAttributeWeights = _D3DXATTRIBUTEWEIGHTS;
  1779.  
  1780.   _D3DXWELDEPSILONSFLAGS = {$IFDEF TYPE_IDENTITY}type {$ENDIF}DWord;
  1781.   {$EXTERNALSYM _D3DXWELDEPSILONSFLAGS}
  1782.   TD3DXWeldEpsilonsFlags = _D3DXWELDEPSILONSFLAGS;
  1783.  
  1784. const
  1785.   D3DXWELDEPSILONS_WELDALL = $1;              // weld all vertices marked by adjacency as being overlapping
  1786.   {$EXTERNALSYM D3DXWELDEPSILONS_WELDALL}
  1787.  
  1788.   D3DXWELDEPSILONS_WELDPARTIALMATCHES = $2;   // if a given vertex component is within epsilon, modify partial matched
  1789.                                                  // vertices so that both components identical AND if all components "equal"
  1790.                                                  // remove one of the vertices
  1791.   {$EXTERNALSYM D3DXWELDEPSILONS_WELDPARTIALMATCHES}
  1792.   D3DXWELDEPSILONS_DONOTREMOVEVERTICES = $4;  // instructs weld to only allow modifications to vertices and not removal
  1793.                                                  // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set
  1794.                                                  // useful to modify vertices to be equal, but not allow vertices to be removed
  1795.   {$EXTERNALSYM D3DXWELDEPSILONS_DONOTREMOVEVERTICES}
  1796.  
  1797. type
  1798.   PD3DXWeldEpsilons = ^TD3DXWeldEpsilons;
  1799.   _D3DXWELDEPSILONS = packed record
  1800.     SkinWeights: Single;
  1801.     Normal: Single;
  1802.     Tex: array[0..7] of Single;
  1803.     Flags: DWord;
  1804.   end;
  1805.   {$EXTERNALSYM _D3DXWELDEPSILONS}
  1806.   D3DXWELDEPSILONS = _D3DXWELDEPSILONS;
  1807.   {$EXTERNALSYM D3DXWELDEPSILONS}
  1808.   TD3DXWeldEpsilons = _D3DXWELDEPSILONS;
  1809.  
  1810.   ID3DXMesh = interface;
  1811.  
  1812.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXBaseMesh);'}
  1813.   {$EXTERNALSYM ID3DXBaseMesh}
  1814.   ID3DXBaseMesh = interface(IUnknown)
  1815.     ['{2A835771-BF4D-43f4-8E14-82A809F17D8A}']
  1816.     // ID3DXBaseMesh
  1817.     function DrawSubset(AttribId: DWord): HResult; stdcall;
  1818.     function GetNumFaces: DWord; stdcall;
  1819.     function GetNumVertices: DWord; stdcall;
  1820.     function GetFVF: DWord; stdcall;
  1821.     function GetDeclaration(out Declaration: TFVFDeclaration): HResult; stdcall;
  1822.     function GetOptions: DWord; stdcall;
  1823.     function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1824.     function CloneMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice8;
  1825.       out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  1826.     function CloneMesh(Options: DWord; pDeclaration: PDWord;
  1827.       ppDevice: IDirect3DDevice8; out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  1828.     function GetVertexBuffer(out ppVB: IDirect3DVertexBuffer8): HResult; stdcall;
  1829.     function GetIndexBuffer(out ppIB: IDirect3DIndexBuffer8): HResult; stdcall;
  1830.     function LockVertexBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1831.     function UnlockVertexBuffer: HResult; stdcall;
  1832.     function LockIndexBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1833.     function UnlockIndexBuffer: HResult; stdcall;
  1834.     function GetAttributeTable(pAttribTable: PD3DXAttributeRange;
  1835.       pAttribTableSize: PDWord): HResult; stdcall;
  1836.  
  1837.     function ConvertPointRepsToAdjacency(pPRep: PDWord; pAdjacency: PDWord): HResult; stdcall;
  1838.     function ConvertAdjacencyToPointReps(pAdjacency: PDWord; pPRep: PDWord): HResult; stdcall;
  1839.     function GenerateAdjacency(Epsilon: Single; pAdjacency: PDWord): HResult; stdcall;
  1840.   end;
  1841.  
  1842.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXMesh);'}
  1843.   {$EXTERNALSYM ID3DXMesh}
  1844.   ID3DXMesh = interface(ID3DXBaseMesh)
  1845.     ['{CCAE5C3B-4DD1-4d0f-997E-4684CA64557F}']
  1846.     // ID3DXMesh
  1847.     function LockAttributeBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1848.     function UnlockAttributeBuffer: HResult; stdcall;
  1849.     function Optimize(Flags: DWord; pAdjacencyIn, pAdjacencyOut: PDWord;
  1850.       pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  1851.       out ppOptMesh: ID3DXMesh): HResult; stdcall;
  1852.     function OptimizeInplace(Flags: DWord; pAdjacencyIn, pAdjacencyOut: PDWord;
  1853.       pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer): HResult; stdcall;
  1854.   end;
  1855.  
  1856.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXPMesh);'}
  1857.   {$EXTERNALSYM ID3DXPMesh}
  1858.   ID3DXPMesh = interface(ID3DXBaseMesh)
  1859.     ['{19FBE386-C282-4659-97BD-CB869B084A6C}']
  1860.     // ID3DXPMesh
  1861.     function ClonePMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice8;
  1862.       out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  1863.     function ClonePMesh(Options: DWord; pDeclaration: PDWord;
  1864.       ppDevice: IDirect3DDevice8; out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  1865.     function SetNumFaces(Faces: DWord): HResult; stdcall;
  1866.     function SetNumVertices(Vertices: DWord): HResult; stdcall;
  1867.     function GetMaxFaces: DWord; stdcall;
  1868.     function GetMinFaces: DWord; stdcall;
  1869.     function GetMaxVertices: DWord; stdcall;
  1870.     function GetMinVertices: DWord; stdcall;
  1871.     function Save(pStream: IStream; pMaterials: PD3DXMaterial;
  1872.        NumMaterials: DWord): HResult; stdcall;
  1873.  
  1874.     function Optimize(Flags: DWord; pAdjacencyOut: PDWord;
  1875.       pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  1876.       out ppOptMesh: ID3DXMesh): HResult; stdcall;
  1877.  
  1878.     function OptimizeBaseLOD(Flags: DWord; pFaceRemap: PDWord): HResult; stdcall;
  1879.     function TrimByFaces(NewFacesMin, NewFacesMax: DWord; rgiFaceRemap, rgiVertRemap: PDWord): HResult; stdcall;
  1880.     function TrimByVertices(NewVerticesMin, NewVerticesMax: DWord; rgiFaceRemap, rgiVertRemap: PDWord): HResult; stdcall;
  1881.  
  1882.     function GetAdjacency(pAdjacency: PDWord): HResult; stdcall;
  1883.   end;
  1884.  
  1885.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXSPMesh);'}
  1886.   {$EXTERNALSYM ID3DXSPMesh}
  1887.   ID3DXSPMesh = interface(IUnknown)
  1888.     ['{4E3CA05C-D4FF-4d11-8A02-16459E08F6F4}']
  1889.     // ID3DXSPMesh
  1890.     function GetNumFaces: DWord; stdcall;
  1891.     function GetNumVertices: DWord; stdcall;
  1892.     function GetFVF: DWord; stdcall;
  1893.     function GetDeclaration(out Declaration: TFVFDeclaration): HResult; stdcall;
  1894.     function GetOptions: DWord; stdcall;
  1895.  
  1896.     function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1897.     function CloneMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice8;
  1898.       pAdjacencyOut, pVertexRemapOut: PDWord;
  1899.       out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  1900.     function CloneMesh(Options: DWord; pDeclaration: PDWord;
  1901.       ppDevice: IDirect3DDevice8; pAdjacencyOut, pVertexRemapOut: PDWord;
  1902.       out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  1903.  
  1904.     function ClonePMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice8;
  1905.       pVertexRemapOut: PDWord; out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  1906.     function ClonePMesh(Options: DWord; pDeclaration: PDWord;
  1907.       ppDevice: IDirect3DDevice8; pVertexRemapOut: PDWord;
  1908.       out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  1909.  
  1910.     function ReduceFaces(Faces: DWord): HResult; stdcall;
  1911.     function ReduceVertices(Vertices: DWord): HResult; stdcall;
  1912.     function GetMaxFaces: DWord; stdcall;
  1913.     function GetMaxVertices: DWord; stdcall;
  1914.     function GetVertexAttributeWeights(pVertexAttributeWeights: PD3DXAttributeWeights): HResult; stdcall;
  1915.     function GetVertexWeights(pVertexWeights: PSingle): HResult; stdcall;
  1916.   end;
  1917.  
  1918. const
  1919.   UNUSED16      = $ffff;
  1920.   {$EXTERNALSYM UNUSED16}
  1921.   UNUSED32      = $ffffffff;
  1922.   {$EXTERNALSYM UNUSED32}
  1923.  
  1924. // ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags
  1925. type
  1926.   _D3DXMESHOPT = {$IFDEF TYPE_IDENTITY}type {$ENDIF}DWord;
  1927.   {$EXTERNALSYM _D3DXMESHOPT}
  1928.   TD3DXMeshOpt = _D3DXMESHOPT;
  1929.  
  1930. const
  1931.   D3DXMESHOPT_COMPACT       = $01000000;
  1932.   {$EXTERNALSYM D3DXMESHOPT_COMPACT}
  1933.   D3DXMESHOPT_ATTRSORT      = $02000000;
  1934.   {$EXTERNALSYM D3DXMESHOPT_ATTRSORT}
  1935.   D3DXMESHOPT_VERTEXCACHE   = $04000000;
  1936.   {$EXTERNALSYM D3DXMESHOPT_VERTEXCACHE}
  1937.   D3DXMESHOPT_STRIPREORDER  = $08000000;
  1938.   {$EXTERNALSYM D3DXMESHOPT_STRIPREORDER}
  1939.   D3DXMESHOPT_IGNOREVERTS   = $10000000;  // optimize faces only; don't touch vertices
  1940.   {$EXTERNALSYM D3DXMESHOPT_IGNOREVERTS}
  1941.   D3DXMESHOPT_SHAREVB       =     $1000;         // same as D3DXMESH_VB_SHARE
  1942.   {$EXTERNALSYM D3DXMESHOPT_SHAREVB}
  1943.  
  1944. // Subset of the mesh that has the same attribute and bone combination.
  1945. // This subset can be rendered in a single draw call
  1946. type
  1947.   PDWordArray = ^TDWordArray;
  1948.   {$NODEFINE PDWordArray}
  1949.   TDWordArray = array[0..8181] of DWord;
  1950.   {$NODEFINE TDWordArray}
  1951.  
  1952.   PD3DXBoneCombination = ^TD3DXBoneCombination;
  1953.   _D3DXBONECOMBINATION = packed record
  1954.     AttribId: DWord;
  1955.     FaceStart: DWord;
  1956.     FaceCount: DWord;
  1957.     VertexStart: DWord;
  1958.     VertexCount: DWord;
  1959.     BoneId: PDWordArray; // [ DWORD* ]  in original d3dx8mesh.h
  1960.   end;
  1961.   {$EXTERNALSYM _D3DXBONECOMBINATION}
  1962.   D3DXBONECOMBINATION = _D3DXBONECOMBINATION;
  1963.   {$EXTERNALSYM D3DXBONECOMBINATION}
  1964.   TD3DXBoneCombination = _D3DXBONECOMBINATION;
  1965.  
  1966.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXSkinMesh);'}
  1967.   {$EXTERNALSYM ID3DXSkinMesh}
  1968.   ID3DXSkinMesh = interface(IUnknown)
  1969.     ['{8DB06ECC-EBFC-408a-9404-3074B4773515}']
  1970.     // close to ID3DXMesh
  1971.     function GetNumFaces: DWord; stdcall;
  1972.     function GetNumVertices: DWord; stdcall;
  1973.     function GetFVF: DWord; stdcall;
  1974.     function GetDeclaration(out Declaration: TFVFDeclaration): HResult; stdcall;
  1975.     function GetOptions: DWord; stdcall;
  1976.     function GetDevice(out ppDevice: IDirect3DDevice8): HResult; stdcall;
  1977.     function GetVertexBuffer(out ppVB: IDirect3DVertexBuffer8): HResult; stdcall;
  1978.     function GetIndexBuffer(out ppIB: IDirect3DIndexBuffer8): HResult; stdcall;
  1979.     function LockVertexBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1980.     function UnlockVertexBuffer: HResult; stdcall;
  1981.     function LockIndexBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1982.     function UnlockIndexBuffer: HResult; stdcall;
  1983.     function LockAttributeBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  1984.     function UnlockAttributeBuffer: HResult; stdcall;
  1985.     // ID3DXSkinMesh
  1986.     function GetNumBones: DWord; stdcall;
  1987.     function GetOriginalMesh(out ppMesh: ID3DXMesh): HResult; stdcall;
  1988.     function SetBoneInfluence(bone, numInfluences: DWord; vertices: PDWord;
  1989.       weights: PSingle): HResult; stdcall;
  1990.     function GetNumBoneInfluences(bone: DWord): DWord; stdcall;
  1991.     function GetBoneInfluence(bone: DWord; vertices: PDWord;
  1992.       weights: PSingle): HResult; stdcall;
  1993.     function GetMaxVertexInfluences(out maxVertexInfluences: DWord): HResult; stdcall;
  1994.     function GetMaxFaceInfluences(out maxFaceInfluences: DWord): HResult; stdcall;
  1995.  
  1996.     function ConvertToBlendedMesh(Options: DWord;
  1997.       pAdjacencyIn, pAdjacencyOut: PDWord;
  1998.       out pNumBoneCombinations: DWord; out ppBoneCombinationTable: ID3DXBuffer;
  1999.       pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  2000.       out ppMesh: ID3DXMesh): HResult; stdcall;
  2001.  
  2002.     function ConvertToIndexedBlendedMesh(Options: DWord;
  2003.       pAdjacencyIn: PDWord; paletteSize: DWord; pAdjacencyOut: PDWord;
  2004.       out pNumBoneCombinations: DWord; out ppBoneCombinationTable: ID3DXBuffer;
  2005.       pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  2006.       out ppMesh: ID3DXMesh): HResult; stdcall;
  2007.  
  2008.     function GenerateSkinnedMesh(Options: DWord; minWeight: Single;
  2009.       pAdjacencyIn, pAdjacencyOut: PDWord;
  2010.       pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  2011.       out ppMesh: ID3DXMesh): HResult; stdcall;
  2012.     function UpdateSkinnedMesh(
  2013.       const pBoneTransforms: TD3DXmatrix; pBoneInvTransforms: PD3DXmatrix;
  2014.       ppMesh: ID3DXMesh): HResult; stdcall;
  2015.   end;
  2016.  
  2017. type
  2018.   IID_ID3DXBaseMesh     = ID3DXBaseMesh;
  2019.   {$EXTERNALSYM IID_ID3DXBaseMesh}
  2020.   IID_ID3DXMesh         = ID3DXMesh;
  2021.   {$EXTERNALSYM IID_ID3DXMesh}
  2022.   IID_ID3DXPMesh        = ID3DXPMesh;
  2023.   {$EXTERNALSYM IID_ID3DXPMesh}
  2024.   IID_ID3DXSPMesh       = ID3DXSPMesh;
  2025.   {$EXTERNALSYM IID_ID3DXSPMesh}
  2026.   IID_ID3DXSkinMesh     = ID3DXSkinMesh;
  2027.   {$EXTERNALSYM IID_ID3DXSkinMesh}
  2028.  
  2029.  
  2030. function D3DXCreateMesh(NumFaces, NumVertices: DWord; Options: DWord;
  2031.   pDeclaration: PDWord; pD3D: IDirect3DDevice8; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  2032. {$EXTERNALSYM D3DXCreateMesh}
  2033.  
  2034. function D3DXCreateMeshFVF(NumFaces, NumVertices: DWord; Options: DWord;
  2035.   FVF: DWord; pD3D: IDirect3DDevice8; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  2036. {$EXTERNALSYM D3DXCreateMeshFVF}
  2037.  
  2038. function D3DXCreateSPMesh(pMesh: ID3DXMesh; pAdjacency: PDWord;
  2039.   pVertexAttributeWeights: PD3DXAttributeWeights; pVertexWeights: PSingle;
  2040.   out ppSMesh: ID3DXSPMesh): HResult; stdcall; external d3dx8dll;
  2041. {$EXTERNALSYM D3DXCreateSPMesh}
  2042.  
  2043. // clean a mesh up for simplification, try to make manifold
  2044. function D3DXCleanMesh(pMeshIn: ID3DXMesh; pAdjacencyIn: PDWord;
  2045.   out ppMeshOut: ID3DXMesh; pAdjacencyOut: PDWord;
  2046.   ppErrorsAndWarnings: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2047. {$EXTERNALSYM D3DXCleanMesh}
  2048.  
  2049. function D3DXValidMesh(pMeshIn: ID3DXMesh; pAdjacency: PDWord;
  2050.   ppErrorsAndWarnings: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2051. {$EXTERNALSYM D3DXValidMesh}
  2052.  
  2053. function D3DXGeneratePMesh(pMesh: ID3DXMesh; pAdjacency: PDWord;
  2054.   pVertexAttributeWeights: PD3DXAttributeWeights; pVertexWeights: PSingle;
  2055.   MinValue: DWord; Options: TD3DMeshSimp; out ppPMesh: ID3DXPMesh): HResult; stdcall; external d3dx8dll;
  2056. {$EXTERNALSYM D3DXGeneratePMesh}
  2057.  
  2058. function D3DXSimplifyMesh(pMesh: ID3DXMesh; pAdjacency: PDWord;
  2059.   pVertexAttributeWeights: PD3DXAttributeWeights; pVertexWeights: PSingle;
  2060.   MinValue: DWord; Options: TD3DMeshSimp; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  2061. {$EXTERNALSYM D3DXSimplifyMesh}
  2062.  
  2063. function D3DXComputeBoundingSphere(const pPointsFVF; NumVertices: DWord;
  2064.   FVF: DWord; out pCenter: TD3DXVector3; out pRadius: Single): HResult; stdcall; external d3dx8dll;
  2065. {$EXTERNALSYM D3DXComputeBoundingSphere}
  2066.  
  2067. function D3DXComputeBoundingBox(const pPointsFVF; NumVertices: DWord;
  2068.   FVF: DWord; out pMin, pMax: TD3DXVector3): HResult; stdcall; external d3dx8dll;
  2069. {$EXTERNALSYM D3DXComputeBoundingBox}
  2070.  
  2071. function D3DXComputeNormals(pMesh: ID3DXBaseMesh; pAdjacency: PDWord): HResult; stdcall; external d3dx8dll;
  2072. {$EXTERNALSYM D3DXComputeNormals}
  2073.  
  2074. function D3DXCreateBuffer(NumBytes: DWord; out ppBuffer: ID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2075. {$EXTERNALSYM D3DXCreateBuffer}
  2076.  
  2077. function D3DXLoadMeshFromX(pFilename: PAnsiChar; Options: DWord;
  2078.   pD3D: IDirect3DDevice8; ppAdjacency, ppMaterials: PID3DXBuffer;
  2079.   pNumMaterials: PDWord; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  2080. {$EXTERNALSYM D3DXLoadMeshFromX}
  2081.  
  2082. function D3DXLoadMeshFromXInMemory(Memory: PByte; SizeOfMemory: DWord;
  2083.   Options: DWord; pD3D: IDirect3DDevice8;
  2084.   ppAdjacency, ppMaterials: PID3DXBuffer;
  2085.   pNumMaterials: PDWord; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  2086. {$EXTERNALSYM D3DXLoadMeshFromXInMemory}
  2087.  
  2088. function D3DXLoadMeshFromXResource(Module: HModule; Name: PAnsiChar; _Type: PAnsiChar;
  2089.   Options: DWord; pD3D: IDirect3DDevice8;
  2090.   ppAdjacency, ppMaterials: PID3DXBuffer;
  2091.   pNumMaterials: PDWord; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  2092. {$EXTERNALSYM D3DXLoadMeshFromXResource}
  2093.  
  2094. function D3DXSaveMeshToX(pFilename: PAnsiChar; ppMesh: ID3DXMesh;
  2095.   pAdjacency: PDWord; pMaterials: PD3DXMaterial; NumMaterials: DWord;
  2096.   Format: DWord): HResult; stdcall; external d3dx8dll;
  2097. {$EXTERNALSYM D3DXSaveMeshToX}
  2098.  
  2099. function D3DXCreatePMeshFromStream(pStream: IStream; Options: DWord;
  2100.   pD3D: IDirect3DDevice8; ppMaterials: PID3DXBuffer;
  2101.   pNumMaterials: PDWord; out ppPMesh: ID3DXPMesh): HResult; stdcall; external d3dx8dll;
  2102. {$EXTERNALSYM D3DXCreatePMeshFromStream}
  2103.  
  2104. function D3DXCreateSkinMesh(NumFaces, NumVertices, NumBones, Options: DWord;
  2105.   pDeclaration: PDWord; pD3D: IDirect3DDevice8;
  2106.   out ppSkinMesh: ID3DXSkinMesh): HResult; stdcall; external d3dx8dll;
  2107. {$EXTERNALSYM D3DXCreateSkinMesh}
  2108.  
  2109. function D3DXCreateSkinMeshFVF(NumFaces, NumVertices, NumBones, Options: DWord;
  2110.   FVF: DWord; pD3D: IDirect3DDevice8;
  2111.   out ppSkinMesh: ID3DXSkinMesh): HResult; stdcall; external d3dx8dll;
  2112. {$EXTERNALSYM D3DXCreateSkinMeshFVF}
  2113.  
  2114. function D3DXCreateSkinMeshFromMesh(pMesh: ID3DXMesh; numBones: DWord;
  2115.   out ppSkinMesh: ID3DXSkinMesh): HResult; stdcall; external d3dx8dll;
  2116. {$EXTERNALSYM D3DXCreateSkinMeshFromMesh}
  2117.  
  2118. function D3DXLoadMeshFromXof(pXofObjMesh: IDirectXFileData;
  2119.   Options: DWord; pD3D: IDirect3DDevice8;
  2120.   ppAdjacency, ppMaterials: PID3DXBuffer;
  2121.   pNumMaterials: PDWord; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  2122. {$EXTERNALSYM D3DXLoadMeshFromXof}
  2123.  
  2124. function D3DXLoadSkinMeshFromXof(pXofObjMesh: IDirectXFileData;
  2125.   Options: DWord; pD3D: IDirect3DDevice8;
  2126.   ppAdjacency, ppMaterials: PID3DXBuffer;
  2127.   pmMatOut: PDWord; ppBoneNames, ppBoneTransforms: PID3DXBuffer;
  2128.   out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx8dll;
  2129. {$EXTERNALSYM D3DXLoadSkinMeshFromXof}
  2130.  
  2131. function D3DXTessellateNPatches(pMeshIn: ID3DXMesh;
  2132.   pAdjacencyIn: PDWord; NumSegs: Single;
  2133.   QuadraticInterpNormals: BOOL; // if false use linear intrep for normals, if true use quadratic
  2134.   out ppMeshOut: ID3DXMesh; ppAdjacencyOut: PDWord): HResult; stdcall; external d3dx8dll;
  2135. {$EXTERNALSYM D3DXTessellateNPatches}
  2136.  
  2137. function D3DXGetFVFVertexSize(FVF: DWord): LongWord; stdcall; external d3dx8dll;
  2138. {$EXTERNALSYM D3DXGetFVFVertexSize}
  2139.  
  2140. function D3DXDeclaratorFromFVF(FVF: DWord; out Declaration: TFVFDeclaration): HResult; stdcall; external d3dx8dll;
  2141. {$EXTERNALSYM D3DXDeclaratorFromFVF}
  2142.  
  2143. function D3DXFVFFromDeclarator(pDeclarator: PDWord; out pFVF: DWord): HResult; stdcall; external d3dx8dll;
  2144. {$EXTERNALSYM D3DXFVFFromDeclarator}
  2145.  
  2146. function D3DXWeldVertices(pMesh: ID3DXMesh; pEpsilons: PD3DXWeldEpsilons;
  2147.   rgdwAdjacencyIn, rgdwAdjacencyOut, pFaceRemap: PDWord;
  2148.   ppVertexRemap: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2149. {$EXTERNALSYM D3DXWeldVertices}
  2150.  
  2151. type
  2152.   PD3DXIntersectInfo = ^TD3DXIntersectInfo;
  2153.   _D3DXINTERSECTINFO = packed record
  2154.     FaceIndex: DWord;                // index of face intersected
  2155.     U: Single;                       // Barycentric Hit Coordinates
  2156.     V: Single;                       // Barycentric Hit Coordinates
  2157.     Dist: Single;                    // Ray-Intersection Parameter Distance
  2158.   end;
  2159.   {$EXTERNALSYM _D3DXINTERSECTINFO}
  2160.   D3DXINTERSECTINFO = _D3DXINTERSECTINFO;
  2161.   {$EXTERNALSYM D3DXINTERSECTINFO}
  2162.   TD3DXIntersectInfo = _D3DXINTERSECTINFO;
  2163.  
  2164. function D3DXIntersect(pMesh: ID3DXBaseMesh;
  2165.   const pRayPos, pRayDir: TD3DXVector3;
  2166.   out pHit: BOOL;                   // True if any faces were intersected
  2167.   pFaceIndex: PDWord;               // index of closest face intersected
  2168.   pU: PSingle;                      // Barycentric Hit Coordinates
  2169.   pV: PSingle;                      // Barycentric Hit Coordinates
  2170.   pDist: PSingle;                   // Ray-Intersection Parameter Distance
  2171.   ppAllHits: PID3DXBuffer;          // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  2172.   pCountOfHits: PDWord              // Number of entries in AllHits array
  2173.  ): HResult; stdcall; external d3dx8dll;
  2174. {$EXTERNALSYM D3DXIntersect}
  2175.  
  2176. function D3DXIntersectSubset(pMesh: ID3DXBaseMesh; AttribId: DWord;
  2177.   const pRayPos, pRayDir: TD3DXVector3;
  2178.   out pHit: BOOL;                   // True if any faces were intersected
  2179.   pFaceIndex: PDWord;               // index of closest face intersected
  2180.   pU: PSingle;                      // Barycentric Hit Coordinates
  2181.   pV: PSingle;                      // Barycentric Hit Coordinates
  2182.   pDist: PSingle;                   // Ray-Intersection Parameter Distance
  2183.   ppAllHits: PID3DXBuffer;          // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  2184.   pCountOfHits: PDWord              // Number of entries in AllHits array
  2185.  ): HResult; stdcall; external d3dx8dll;
  2186. {$EXTERNALSYM D3DXIntersectSubset}
  2187.  
  2188.  
  2189. function D3DXSplitMesh(pMeshIn: ID3DXMesh; pAdjacencyIn: PDWord;
  2190.   MaxSize, Options: DWord;
  2191.   out pMeshesOut: DWord; out ppMeshArrayOut: ID3DXBuffer;
  2192.   ppAdjacencyArrayOut, ppFaceRemapArrayOut, ppVertRemapArrayOut: PID3DXBuffer
  2193.  ): HResult; stdcall; external d3dx8dll;
  2194. {$EXTERNALSYM D3DXSplitMesh}
  2195.  
  2196. function D3DXIntersectTri(
  2197.     const p0: TD3DXVector3;           // Triangle vertex 0 position
  2198.     const p1: TD3DXVector3;           // Triangle vertex 1 position
  2199.     const p2: TD3DXVector3;           // Triangle vertex 2 position
  2200.     const pRayPos: TD3DXVector3;      // Ray origin
  2201.     const pRayDir: TD3DXVector3;      // Ray direction
  2202.     out pU: Single;                   // Barycentric Hit Coordinates
  2203.     out pV: Single;                   // Barycentric Hit Coordinates
  2204.     out pDist: Single                 // Ray-Intersection Parameter Distance
  2205.  ): HResult; stdcall; external d3dx8dll;
  2206. {$EXTERNALSYM D3DXIntersectTri}
  2207.  
  2208. function D3DXSphereBoundProbe(const pCenter: TD3DXVector3; Radius: Single;
  2209.   out pRayPosition, pRayDirection: TD3DXVector3): BOOL; stdcall; external d3dx8dll;
  2210. {$EXTERNALSYM D3DXSphereBoundProbe}
  2211.  
  2212. function D3DXBoxBoundProbe(const pMin, pMax: TD3DXVector3;
  2213.   out pRayPosition, pRayDirection: TD3DXVector3): BOOL; stdcall; external d3dx8dll;
  2214. {$EXTERNALSYM D3DXBoxBoundProbe}
  2215.  
  2216. type
  2217.   _D3DXERR = HResult;
  2218.   {$EXTERNALSYM _D3DXERR}
  2219.  
  2220. {$IFDEF DXG_COMPAT}
  2221. const
  2222.   MAKE_D3DHRESULT_R = MAKE_D3DHRESULT;
  2223. {$ENDIF}
  2224.  
  2225. const
  2226.   D3DXERR_CANNOTMODIFYINDEXBUFFER       = HResult(MAKE_D3DHRESULT_R or 2900);
  2227.   {$EXTERNALSYM D3DXERR_CANNOTMODIFYINDEXBUFFER}
  2228.   D3DXERR_INVALIDMESH      = HResult(MAKE_D3DHRESULT_R or 2901);
  2229.   {$EXTERNALSYM D3DXERR_INVALIDMESH}
  2230.   D3DXERR_CANNOTATTRSORT                = HResult(MAKE_D3DHRESULT_R or 2902);
  2231.   {$EXTERNALSYM D3DXERR_CANNOTATTRSORT}
  2232.   D3DXERR_SKINNINGNOTSUPPORTED    = HResult(MAKE_D3DHRESULT_R or 2903);
  2233.   {$EXTERNALSYM D3DXERR_SKINNINGNOTSUPPORTED}
  2234.   D3DXERR_TOOMANYINFLUENCES    = HResult(MAKE_D3DHRESULT_R or 2904);
  2235.   {$EXTERNALSYM D3DXERR_TOOMANYINFLUENCES}
  2236.   D3DXERR_INVALIDDATA                   = HResult(MAKE_D3DHRESULT_R or 2905);
  2237.   {$EXTERNALSYM D3DXERR_INVALIDDATA}
  2238.   D3DXERR_LOADEDMESHASNODATA            = HResult(MAKE_D3DHRESULT_R or 2906);
  2239.   {$EXTERNALSYM D3DXERR_LOADEDMESHASNODATA}
  2240.  
  2241. const
  2242.   D3DX_COMP_TANGENT_NONE = $FFFFFFFF;
  2243.   {$EXTERNALSYM D3DX_COMP_TANGENT_NONE}
  2244.  
  2245. function D3DXComputeTangent(InMesh: ID3DXMesh; TexStage: DWord;
  2246.   OutMesh: ID3DXMesh; TexStageUVec, TexStageVVec: DWord;
  2247.   Wrap: DWord; Adjacency: PDWord): HResult; stdcall; external d3dx8dll;
  2248. {$EXTERNALSYM D3DXComputeTangent}
  2249.  
  2250. function D3DXConvertMeshSubsetToSingleStrip(MeshIn: ID3DXBaseMesh;
  2251.   AttribId: DWord; IBOptions: DWord;
  2252.   out ppIndexBuffer: IDirect3DIndexBuffer8; pNumIndices: PDWord
  2253.  ): HResult; stdcall; external d3dx8dll;
  2254. {$EXTERNALSYM D3DXConvertMeshSubsetToSingleStrip}
  2255.  
  2256. function D3DXConvertMeshSubsetToStrips(MeshIn: ID3DXBaseMesh;
  2257.   AttribId: DWord; IBOptions: DWord;
  2258.   out ppIndexBuffer: IDirect3DIndexBuffer8; pNumIndices: PDWord;
  2259.   ppStripLengths: PID3DXBuffer; pNumStrips: PDWord): HResult; stdcall; external d3dx8dll;
  2260. {$EXTERNALSYM D3DXConvertMeshSubsetToStrips}
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268. ///////////////////////////////////////////////////////////////////////////
  2269. //
  2270. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  2271. //
  2272. //  File:       d3dx8shapes.h
  2273. //  Content:    D3DX simple shapes
  2274. //
  2275. ///////////////////////////////////////////////////////////////////////////
  2276.  
  2277.  
  2278. ///////////////////////////////////////////////////////////////////////////
  2279. // Functions:
  2280. ///////////////////////////////////////////////////////////////////////////
  2281.  
  2282.  
  2283. //-------------------------------------------------------------------------
  2284. // D3DXCreatePolygon:
  2285. // ------------------
  2286. // Creates a mesh containing an n-sided polygon.  The polygon is centered
  2287. // at the origin.
  2288. //
  2289. // Parameters:
  2290. //
  2291. //  pDevice     The D3D device with which the mesh is going to be used.
  2292. //  Length      Length of each side.
  2293. //  Sides       Number of sides the polygon has.  (Must be >= 3)
  2294. //  ppMesh      The mesh object which will be created
  2295. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  2296. //-------------------------------------------------------------------------
  2297. function D3DXCreatePolygon(ppDevice: IDirect3DDevice8;
  2298.   Length: Single;
  2299.   Sides: LongWord;
  2300.   out ppMesh: ID3DXMesh;
  2301.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2302. {$EXTERNALSYM D3DXCreatePolygon}
  2303.  
  2304.  
  2305. //-------------------------------------------------------------------------
  2306. // D3DXCreateBox:
  2307. // --------------
  2308. // Creates a mesh containing an axis-aligned box.  The box is centered at
  2309. // the origin.
  2310. //
  2311. // Parameters:
  2312. //
  2313. //  pDevice     The D3D device with which the mesh is going to be used.
  2314. //  Width       Width of box (along X-axis)
  2315. //  Height      Height of box (along Y-axis)
  2316. //  Depth       Depth of box (along Z-axis)
  2317. //  ppMesh      The mesh object which will be created
  2318. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  2319. //-------------------------------------------------------------------------
  2320. function D3DXCreateBox(ppDevice: IDirect3DDevice8;
  2321.   Width,
  2322.   Height,
  2323.   Depth: Single;
  2324.   out ppMesh: ID3DXMesh;
  2325.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2326. {$EXTERNALSYM D3DXCreateBox}
  2327.  
  2328.  
  2329. //-------------------------------------------------------------------------
  2330. // D3DXCreateCylinder:
  2331. // -------------------
  2332. // Creates a mesh containing a cylinder.  The generated cylinder is
  2333. // centered at the origin, and its axis is aligned with the Z-axis.
  2334. //
  2335. // Parameters:
  2336. //
  2337. //  pDevice     The D3D device with which the mesh is going to be used.
  2338. //  Radius1     Radius at -Z end (should be >= 0.0f)
  2339. //  Radius2     Radius at +Z end (should be >= 0.0f)
  2340. //  Length      Length of cylinder (along Z-axis)
  2341. //  Slices      Number of slices about the main axis
  2342. //  Stacks      Number of stacks along the main axis
  2343. //  ppMesh      The mesh object which will be created
  2344. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  2345. //-------------------------------------------------------------------------
  2346. function D3DXCreateCylinder(ppDevice: IDirect3DDevice8;
  2347.   Radius1,
  2348.   Radius2,
  2349.   Length: Single;
  2350.   Slices,
  2351.   Stacks: LongWord;
  2352.   out ppMesh: ID3DXMesh;
  2353.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2354. {$EXTERNALSYM D3DXCreateCylinder}
  2355.  
  2356.  
  2357. //-------------------------------------------------------------------------
  2358. // D3DXCreateSphere:
  2359. // -----------------
  2360. // Creates a mesh containing a sphere.  The sphere is centered at the
  2361. // origin.
  2362. //
  2363. // Parameters:
  2364. //
  2365. //  pDevice     The D3D device with which the mesh is going to be used.
  2366. //  Radius      Radius of the sphere (should be >= 0.0f)
  2367. //  Slices      Number of slices about the main axis
  2368. //  Stacks      Number of stacks along the main axis
  2369. //  ppMesh      The mesh object which will be created
  2370. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  2371. //-------------------------------------------------------------------------
  2372. function D3DXCreateSphere(ppDevice: IDirect3DDevice8;
  2373.   Radius: Single;
  2374.   Slices,
  2375.   Stacks: LongWord;
  2376.   out ppMesh: ID3DXMesh;
  2377.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2378. {$EXTERNALSYM D3DXCreateSphere}
  2379.  
  2380.  
  2381. //-------------------------------------------------------------------------
  2382. // D3DXCreateTorus:
  2383. // ----------------
  2384. // Creates a mesh containing a torus.  The generated torus is centered at
  2385. // the origin, and its axis is aligned with the Z-axis.
  2386. //
  2387. // Parameters:
  2388. //
  2389. //  pDevice     The D3D device with which the mesh is going to be used.
  2390. //  InnerRadius Inner radius of the torus (should be >= 0.0f)
  2391. //  OuterRadius Outer radius of the torue (should be >= 0.0f)
  2392. //  Sides       Number of sides in a cross-section (must be >= 3)
  2393. //  Rings       Number of rings making up the torus (must be >= 3)
  2394. //  ppMesh      The mesh object which will be created
  2395. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  2396. //-------------------------------------------------------------------------
  2397. function D3DXCreateTorus(ppDevice: IDirect3DDevice8;
  2398.   InnerRadius,
  2399.   OuterRadius: Single;
  2400.   Sides,
  2401.   Rings: LongWord;
  2402.   out ppMesh: ID3DXMesh;
  2403.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2404. {$EXTERNALSYM D3DXCreateTorus}
  2405.  
  2406.  
  2407. //-------------------------------------------------------------------------
  2408. // D3DXCreateTeapot:
  2409. // -----------------
  2410. // Creates a mesh containing a teapot.
  2411. //
  2412. // Parameters:
  2413. //
  2414. //  pDevice     The D3D device with which the mesh is going to be used.
  2415. //  ppMesh      The mesh object which will be created
  2416. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  2417. //-------------------------------------------------------------------------
  2418. function D3DXCreateTeapot(ppDevice: IDirect3DDevice8;
  2419.   out ppMesh: ID3DXMesh;
  2420.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx8dll;
  2421. {$EXTERNALSYM D3DXCreateTeapot}
  2422.  
  2423.  
  2424. //-------------------------------------------------------------------------
  2425. // D3DXCreateText:
  2426. // ---------------
  2427. // Creates a mesh containing the specified text using the font associated
  2428. // with the device context.
  2429. //
  2430. // Parameters:
  2431. //
  2432. //  pDevice       The D3D device with which the mesh is going to be used.
  2433. //  hDC           Device context, with desired font selected
  2434. //  pText         Text to generate
  2435. //  Deviation     Maximum chordal deviation from true font outlines
  2436. //  Extrusion     Amount to extrude text in -Z direction
  2437. //  ppMesh        The mesh object which will be created
  2438. //  pGlyphMetrics Address of buffer to receive glyph metric data (or NULL)
  2439. //-------------------------------------------------------------------------
  2440.  
  2441. function D3DXCreateTextA(ppDevice: IDirect3DDevice8;
  2442.   hDC: HDC;
  2443.   pText: PAnsiChar;
  2444.   Deviation: Single;
  2445.   Extrusion: Single;
  2446.   out ppMesh: ID3DXMesh;
  2447.   ppAdjacency: PID3DXBuffer;
  2448.   pGlyphMetrics: PGlyphMetricsFloat): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextA';
  2449. {$EXTERNALSYM D3DXCreateTextA}
  2450.  
  2451. function D3DXCreateTextW(ppDevice: IDirect3DDevice8;
  2452.   hDC: HDC;
  2453.   pText: PWideChar;
  2454.   Deviation: Single;
  2455.   Extrusion: Single;
  2456.   out ppMesh: ID3DXMesh;
  2457.   ppAdjacency: PID3DXBuffer;
  2458.   pGlyphMetrics: PGlyphMetricsFloat): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextW';
  2459. {$EXTERNALSYM D3DXCreateTextW}
  2460.  
  2461. function D3DXCreateText(ppDevice: IDirect3DDevice8;
  2462.   hDC: HDC;
  2463.   pText: PChar;
  2464.   Deviation: Single;
  2465.   Extrusion: Single;
  2466.   out ppMesh: ID3DXMesh;
  2467.   ppAdjacency: PID3DXBuffer;
  2468.   pGlyphMetrics: PGlyphMetricsFloat): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextA';
  2469. {$EXTERNALSYM D3DXCreateText}
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477. //////////////////////////////////////////////////////////////////////////////
  2478. //
  2479. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  2480. //
  2481. //  File:       d3dx8tex.h
  2482. //  Content:    D3DX texturing APIs
  2483. //
  2484. //////////////////////////////////////////////////////////////////////////////
  2485.  
  2486. //----------------------------------------------------------------------------
  2487. // D3DX_FILTER flags:
  2488. // ------------------
  2489. //
  2490. // A valid filter must contain one of these values:
  2491. //
  2492. //  D3DX_FILTER_NONE
  2493. //      No scaling or filtering will take place.  Pixels outside the bounds
  2494. //      of the source image are assumed to be transparent black.
  2495. //  D3DX_FILTER_POINT
  2496. //      Each destination pixel is computed by sampling the nearest pixel
  2497. //      from the source image.
  2498. //  D3DX_FILTER_LINEAR
  2499. //      Each destination pixel is computed by linearly interpolating between
  2500. //      the nearest pixels in the source image.  This filter works best
  2501. //      when the scale on each axis is less than 2.
  2502. //  D3DX_FILTER_TRIANGLE
  2503. //      Every pixel in the source image contributes equally to the
  2504. //      destination image.  This is the slowest of all the filters.
  2505. //  D3DX_FILTER_BOX
  2506. //      Each pixel is computed by averaging a 2x2(x2) box pixels from
  2507. //      the source image. Only works when the dimensions of the
  2508. //      destination are half those of the source. (as with mip maps)
  2509. //
  2510. // And can be OR'd with any of these optional flags:
  2511. //
  2512. //  D3DX_FILTER_MIRROR_U
  2513. //      Indicates that pixels off the edge of the texture on the U-axis
  2514. //      should be mirrored, not wraped.
  2515. //  D3DX_FILTER_MIRROR_V
  2516. //      Indicates that pixels off the edge of the texture on the V-axis
  2517. //      should be mirrored, not wraped.
  2518. //  D3DX_FILTER_MIRROR_W
  2519. //      Indicates that pixels off the edge of the texture on the W-axis
  2520. //      should be mirrored, not wraped.
  2521. //  D3DX_FILTER_MIRROR
  2522. //      Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V |
  2523. //      D3DX_FILTER_MIRROR_V
  2524. //  D3DX_FILTER_DITHER
  2525. //      Dithers the resulting image.
  2526. //
  2527. //----------------------------------------------------------------------------
  2528.  
  2529. const
  2530.   D3DX_FILTER_NONE      = (1 shl 0);
  2531.   {$EXTERNALSYM D3DX_FILTER_NONE}
  2532.   D3DX_FILTER_POINT     = (2 shl 0);
  2533.   {$EXTERNALSYM D3DX_FILTER_POINT}
  2534.   D3DX_FILTER_LINEAR    = (3 shl 0);
  2535.   {$EXTERNALSYM D3DX_FILTER_LINEAR}
  2536.   D3DX_FILTER_TRIANGLE  = (4 shl 0);
  2537.   {$EXTERNALSYM D3DX_FILTER_TRIANGLE}
  2538.   D3DX_FILTER_BOX       = (5 shl 0);
  2539.   {$EXTERNALSYM D3DX_FILTER_BOX}
  2540.  
  2541.   D3DX_FILTER_MIRROR_U  = (1 shl 16);
  2542.   {$EXTERNALSYM D3DX_FILTER_MIRROR_U}
  2543.   D3DX_FILTER_MIRROR_V  = (2 shl 16);
  2544.   {$EXTERNALSYM D3DX_FILTER_MIRROR_V}
  2545.   D3DX_FILTER_MIRROR_W  = (4 shl 16);
  2546.   {$EXTERNALSYM D3DX_FILTER_MIRROR_W}
  2547.   D3DX_FILTER_MIRROR    = (7 shl 16);
  2548.   {$EXTERNALSYM D3DX_FILTER_MIRROR}
  2549.   D3DX_FILTER_DITHER    = (8 shl 16);
  2550.   {$EXTERNALSYM D3DX_FILTER_DITHER}
  2551.  
  2552.  
  2553. //----------------------------------------------------------------------------
  2554. // D3DX_NORMALMAP flags:
  2555. // ---------------------
  2556. // These flags are used to control how D3DXComputeNormalMap generates normal
  2557. // maps.  Any number of these flags may be OR'd together in any combination.
  2558. //
  2559. //  D3DX_NORMALMAP_MIRROR_U
  2560. //      Indicates that pixels off the edge of the texture on the U-axis
  2561. //      should be mirrored, not wraped.
  2562. //  D3DX_NORMALMAP_MIRROR_V
  2563. //      Indicates that pixels off the edge of the texture on the V-axis
  2564. //      should be mirrored, not wraped.
  2565. //  D3DX_NORMALMAP_MIRROR
  2566. //      Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V
  2567. //  D3DX_NORMALMAP_INVERTSIGN
  2568. //      Inverts the direction of each normal
  2569. //  D3DX_NORMALMAP_COMPUTE_OCCLUSION
  2570. //      Compute the per pixel Occlusion term and encodes it into the alpha.
  2571. //      An Alpha of 1 means that the pixel is not obscured in anyway, and
  2572. //      an alpha of 0 would mean that the pixel is completly obscured.
  2573. //
  2574. //----------------------------------------------------------------------------
  2575.  
  2576. //----------------------------------------------------------------------------
  2577.  
  2578. const
  2579.   D3DX_NORMALMAP_MIRROR_U     = (1 shl 16);
  2580.   {$EXTERNALSYM D3DX_NORMALMAP_MIRROR_U}
  2581.   D3DX_NORMALMAP_MIRROR_V     = (2 shl 16);
  2582.   {$EXTERNALSYM D3DX_NORMALMAP_MIRROR_V}
  2583.   D3DX_NORMALMAP_MIRROR       = (3 shl 16);
  2584.   {$EXTERNALSYM D3DX_NORMALMAP_MIRROR}
  2585.   D3DX_NORMALMAP_INVERTSIGN   = (8 shl 16);
  2586.   {$EXTERNALSYM D3DX_NORMALMAP_INVERTSIGN}
  2587.   D3DX_NORMALMAP_COMPUTE_OCCLUSION = (16 shl 16);
  2588.   {$EXTERNALSYM D3DX_NORMALMAP_COMPUTE_OCCLUSION}
  2589.  
  2590.  
  2591. //----------------------------------------------------------------------------
  2592. // D3DX_CHANNEL flags:
  2593. // -------------------
  2594. // These flags are used by functions which operate on or more channels
  2595. // in a texture.
  2596. //
  2597. // D3DX_CHANNEL_RED
  2598. //     Indicates the red channel should be used
  2599. // D3DX_CHANNEL_BLUE
  2600. //     Indicates the blue channel should be used
  2601. // D3DX_CHANNEL_GREEN
  2602. //     Indicates the green channel should be used
  2603. // D3DX_CHANNEL_ALPHA
  2604. //     Indicates the alpha channel should be used
  2605. // D3DX_CHANNEL_LUMINANCE
  2606. //     Indicates the luminaces of the red green and blue channels should be
  2607. //     used.
  2608. //
  2609. //----------------------------------------------------------------------------
  2610.  
  2611. const
  2612.   D3DX_CHANNEL_RED            = (1 shl 0);
  2613.   {$EXTERNALSYM D3DX_CHANNEL_RED}
  2614.   D3DX_CHANNEL_BLUE           = (1 shl 1);
  2615.   {$EXTERNALSYM D3DX_CHANNEL_BLUE}
  2616.   D3DX_CHANNEL_GREEN          = (1 shl 2);
  2617.   {$EXTERNALSYM D3DX_CHANNEL_GREEN}
  2618.   D3DX_CHANNEL_ALPHA          = (1 shl 3);
  2619.   {$EXTERNALSYM D3DX_CHANNEL_ALPHA}
  2620.   D3DX_CHANNEL_LUMINANCE      = (1 shl 4);
  2621.   {$EXTERNALSYM D3DX_CHANNEL_LUMINANCE}
  2622.  
  2623.  
  2624. //----------------------------------------------------------------------------
  2625. // D3DXIMAGE_FILEFORMAT:
  2626. // ---------------------
  2627. // This enum is used to describe supported image file formats.
  2628. //
  2629. //----------------------------------------------------------------------------
  2630.  
  2631. type
  2632.   PD3DXImageFileFormat = ^TD3DXImageFileFormat;
  2633.   _D3DXIMAGE_FILEFORMAT = (
  2634.     D3DXIFF_BMP        {= 0},
  2635.     D3DXIFF_JPG        {= 1},
  2636.     D3DXIFF_TGA        {= 2},
  2637.     D3DXIFF_PNG        {= 3},
  2638.     D3DXIFF_DDS        {= 4},
  2639.     D3DXIFF_PPM        {= 5},
  2640.     D3DXIFF_DIB        {= 6}
  2641.   );
  2642.   {$EXTERNALSYM _D3DXIMAGE_FILEFORMAT}
  2643.   D3DXIMAGE_FILEFORMAT = _D3DXIMAGE_FILEFORMAT;
  2644.   {$EXTERNALSYM D3DXIMAGE_FILEFORMAT}
  2645.   TD3DXImageFileFormat = _D3DXIMAGE_FILEFORMAT;
  2646.  
  2647.  
  2648. //----------------------------------------------------------------------------
  2649. // LPD3DXFILL2D and LPD3DXFILL3D:
  2650. // ------------------------------
  2651. // Function types used by the texture fill functions.
  2652. //
  2653. // Parameters:
  2654. //  pOut
  2655. //      Pointer to a vector which the function uses to return its result.
  2656. //      X,Y,Z,W will be mapped to R,G,B,A respectivly.
  2657. //  pTexCoord
  2658. //      Pointer to a vector containing the coordinates of the texel currently
  2659. //      being evaluated.  Textures and VolumeTexture texcoord components
  2660. //      range from 0 to 1. CubeTexture texcoord component range from -1 to 1.
  2661. //  pTexelSize
  2662. //      Pointer to a vector containing the dimensions of the current texel.
  2663. //  pData
  2664. //      Pointer to user data.
  2665. //
  2666. //----------------------------------------------------------------------------
  2667.  
  2668. type
  2669.   // typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData);
  2670.   LPD3DXFILL2D = procedure (out pOut: TD3DXVector4; const pTexCoord, pTexelSize: TD3DXVector2; var pData);
  2671.   {$EXTERNALSYM LPD3DXFILL2D}
  2672.   TD3DXFill2D = LPD3DXFILL2D;
  2673.   // typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData);
  2674.   LPD3DXFILL3D = procedure (out pOut: TD3DXVector4; const pTexCoord, pTexelSize: TD3DXVector3; var pData);
  2675.   {$EXTERNALSYM LPD3DXFILL3D}
  2676.   TD3DXFill3D = LPD3DXFILL3D;
  2677.  
  2678.  
  2679. //----------------------------------------------------------------------------
  2680. // D3DXIMAGE_INFO:
  2681. // ---------------
  2682. // This structure is used to return a rough description of what the
  2683. // the original contents of an image file looked like.
  2684. //
  2685. //  Width
  2686. //      Width of original image in pixels
  2687. //  Height
  2688. //      Height of original image in pixels
  2689. //  Depth
  2690. //      Depth of original image in pixels
  2691. //  MipLevels
  2692. //      Number of mip levels in original image
  2693. //  Format
  2694. //      D3D format which most closely describes the data in original image
  2695. //  ResourceType
  2696. //      D3DRESOURCETYPE representing the type of texture stored in the file.
  2697. //      D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE.
  2698. //  ImageFileFormat
  2699. //      D3DXIMAGE_FILEFORMAT representing the format of the image file.
  2700. //
  2701. //----------------------------------------------------------------------------
  2702.  
  2703. type
  2704.   PD3DXImageInfo = ^TD3DXImageInfo;
  2705.   _D3DXIMAGE_INFO = packed record
  2706.     Width:      LongWord;
  2707.     Height:     LongWord;
  2708.     Depth:      LongWord;
  2709.     MipLevels:  LongWord;
  2710.     Format:     TD3DFormat;
  2711.     ResourceType: TD3DResourceType;
  2712.     ImageFileFormat: TD3DXImageFileFormat;
  2713.   end;
  2714.   {$EXTERNALSYM _D3DXIMAGE_INFO}
  2715.   D3DXIMAGE_INFO = _D3DXIMAGE_INFO;
  2716.   {$EXTERNALSYM D3DXIMAGE_INFO}
  2717.   TD3DXImageInfo = _D3DXIMAGE_INFO;
  2718.  
  2719.  
  2720. //////////////////////////////////////////////////////////////////////////////
  2721. // Image File APIs ///////////////////////////////////////////////////////////
  2722. //////////////////////////////////////////////////////////////////////////////
  2723.  
  2724. //----------------------------------------------------------------------------
  2725. // GetImageInfoFromFile/Resource:
  2726. // ------------------------------
  2727. // Fills in a D3DXIMAGE_INFO struct with information about an image file.
  2728. //
  2729. // Parameters:
  2730. //  pSrcFile
  2731. //      File name of the source image.
  2732. //  pSrcModule
  2733. //      Module where resource is located, or NULL for module associated
  2734. //      with image the os used to create the current process.
  2735. //  pSrcResource
  2736. //      Resource name
  2737. //  pSrcData
  2738. //      Pointer to file in memory.
  2739. //  SrcDataSize
  2740. //      Size in bytes of file in memory.
  2741. //  pSrcInfo
  2742. //      Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  2743. //      description of the data in the source image file.
  2744. //
  2745. //----------------------------------------------------------------------------
  2746.  
  2747. function D3DXGetImageInfoFromFileA(
  2748.   pSrcFile: PAnsiChar;
  2749.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromFileA';
  2750. {$EXTERNALSYM D3DXGetImageInfoFromFileA}
  2751.  
  2752. function D3DXGetImageInfoFromFileW(
  2753.   pSrcFile: PWideChar;
  2754.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromFileW';
  2755. {$EXTERNALSYM D3DXGetImageInfoFromFileW}
  2756.  
  2757. function D3DXGetImageInfoFromFile(
  2758.   pSrcFile: PChar;
  2759.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromFileA';
  2760. {$EXTERNALSYM D3DXGetImageInfoFromFile}
  2761.  
  2762.  
  2763. function D3DXGetImageInfoFromResourceA(
  2764.   hSrcModule: HModule;
  2765.   pSrcResource: PAnsiChar;
  2766.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromResourceA';
  2767. {$EXTERNALSYM D3DXGetImageInfoFromResourceA}
  2768.  
  2769. function D3DXGetImageInfoFromResourceW(
  2770.   hSrcModule: HModule;
  2771.   pSrcResource: PWideChar;
  2772.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromResourceW';
  2773. {$EXTERNALSYM D3DXGetImageInfoFromResourceW}
  2774.  
  2775. function D3DXGetImageInfoFromResource(
  2776.   hSrcModule: HModule;
  2777.   pSrcResource: PChar;
  2778.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXGetImageInfoFromResourceA';
  2779. {$EXTERNALSYM D3DXGetImageInfoFromResource}
  2780.  
  2781.  
  2782. function D3DXGetImageInfoFromFileInMemory(
  2783.   const pSrcData;
  2784.   SrcDataSize: LongWord;
  2785.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx8dll;
  2786. {$EXTERNALSYM D3DXGetImageInfoFromFileInMemory}
  2787.  
  2788.  
  2789. //////////////////////////////////////////////////////////////////////////////
  2790. // Load/Save Surface APIs ////////////////////////////////////////////////////
  2791. //////////////////////////////////////////////////////////////////////////////
  2792.  
  2793.  
  2794. //----------------------------------------------------------------------------
  2795. // D3DXLoadSurfaceFromFile/Resource:
  2796. // ---------------------------------
  2797. // Load surface from a file or resource
  2798. //
  2799. // Parameters:
  2800. //  pDestSurface
  2801. //      Destination surface, which will receive the image.
  2802. //  pDestPalette
  2803. //      Destination palette of 256 colors, or NULL
  2804. //  pDestRect
  2805. //      Destination rectangle, or NULL for entire surface
  2806. //  pSrcFile
  2807. //      File name of the source image.
  2808. //  pSrcModule
  2809. //      Module where resource is located, or NULL for module associated
  2810. //      with image the os used to create the current process.
  2811. //  pSrcResource
  2812. //      Resource name
  2813. //  pSrcData
  2814. //      Pointer to file in memory.
  2815. //  SrcDataSize
  2816. //      Size in bytes of file in memory.
  2817. //  pSrcRect
  2818. //      Source rectangle, or NULL for entire image
  2819. //  Filter
  2820. //      D3DX_FILTER flags controlling how the image is filtered.
  2821. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2822. //  ColorKey
  2823. //      Color to replace with transparent black, or 0 to disable colorkey.
  2824. //      This is always a 32-bit ARGB color, independent of the source image
  2825. //      format.  Alpha is significant, and should usually be set to FF for
  2826. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  2827. //  pSrcInfo
  2828. //      Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  2829. //      description of the data in the source image file, or NULL.
  2830. //
  2831. //----------------------------------------------------------------------------
  2832. function D3DXLoadSurfaceFromFileA(
  2833.   pDestSurface: IDirect3DSurface8;
  2834.   pDestPalette: PPaletteEntry;
  2835.   pDestRect: PRect;
  2836.   pSrcFile: PAnsiChar;
  2837.   pSrcRect: PRect;
  2838.   Filter: DWord;
  2839.   ColorKey: TD3DColor;
  2840.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromFileA';
  2841. {$EXTERNALSYM D3DXLoadSurfaceFromFileA}
  2842.  
  2843. function D3DXLoadSurfaceFromFileW(
  2844.   pDestSurface: IDirect3DSurface8;
  2845.   pDestPalette: PPaletteEntry;
  2846.   pDestRect: PRect;
  2847.   pSrcFile: PWideChar;
  2848.   pSrcRect: PRect;
  2849.   Filter: DWord;
  2850.   ColorKey: TD3DColor;
  2851.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromFileW';
  2852. {$EXTERNALSYM D3DXLoadSurfaceFromFileW}
  2853.  
  2854. function D3DXLoadSurfaceFromFile(
  2855.   pDestSurface: IDirect3DSurface8;
  2856.   pDestPalette: PPaletteEntry;
  2857.   pDestRect: PRect;
  2858.   pSrcFile: PChar;
  2859.   pSrcRect: PRect;
  2860.   Filter: DWord;
  2861.   ColorKey: TD3DColor;
  2862.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromFileA';
  2863. {$EXTERNALSYM D3DXLoadSurfaceFromFile}
  2864.  
  2865.  
  2866.  
  2867. function D3DXLoadSurfaceFromResourceA(
  2868.   pDestSurface: IDirect3DSurface8;
  2869.   pDestPalette: PPaletteEntry;
  2870.   pDestRect: PRect;
  2871.   hSrcModule: HModule;
  2872.   pSrcResource: PAnsiChar;
  2873.   pSrcRect: PRect;
  2874.   Filter: DWord;
  2875.   ColorKey: TD3DColor;
  2876.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromResourceA';
  2877. {$EXTERNALSYM D3DXLoadSurfaceFromResourceA}
  2878.  
  2879. function D3DXLoadSurfaceFromResourceW(
  2880.   pDestSurface: IDirect3DSurface8;
  2881.   pDestPalette: PPaletteEntry;
  2882.   pDestRect: PRect;
  2883.   hSrcModule: HModule;
  2884.   pSrcResource: PWideChar;
  2885.   pSrcRect: PRect;
  2886.   Filter: DWord;
  2887.   ColorKey: TD3DColor;
  2888.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromResourceW';
  2889. {$EXTERNALSYM D3DXLoadSurfaceFromResourceW}
  2890.  
  2891. function D3DXLoadSurfaceFromResource(
  2892.   pDestSurface: IDirect3DSurface8;
  2893.   pDestPalette: PPaletteEntry;
  2894.   pDestRect: PRect;
  2895.   hSrcModule: HModule;
  2896.   pSrcResource: PChar;
  2897.   pSrcRect: PRect;
  2898.   Filter: DWord;
  2899.   ColorKey: TD3DColor;
  2900.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadSurfaceFromResourceA';
  2901. {$EXTERNALSYM D3DXLoadSurfaceFromResource}
  2902.  
  2903.  
  2904.  
  2905. function D3DXLoadSurfaceFromFileInMemory(
  2906.   pDestSurface: IDirect3DSurface8;
  2907.   pDestPalette: PPaletteEntry;
  2908.   pDestRect: PRect;
  2909.   const pSrcData;
  2910.   SrcDataSize: LongWord;
  2911.   pSrcRect: PRect;
  2912.   Filter: DWord;
  2913.   ColorKey: TD3DColor;
  2914.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll;
  2915. {$EXTERNALSYM D3DXLoadSurfaceFromFileInMemory}
  2916.  
  2917.  
  2918.  
  2919. //----------------------------------------------------------------------------
  2920. // D3DXLoadSurfaceFromSurface:
  2921. // ---------------------------
  2922. // Load surface from another surface (with color conversion)
  2923. //
  2924. // Parameters:
  2925. //  pDestSurface
  2926. //      Destination surface, which will receive the image.
  2927. //  pDestPalette
  2928. //      Destination palette of 256 colors, or NULL
  2929. //  pDestRect
  2930. //      Destination rectangle, or NULL for entire surface
  2931. //  pSrcSurface
  2932. //      Source surface
  2933. //  pSrcPalette
  2934. //      Source palette of 256 colors, or NULL
  2935. //  pSrcRect
  2936. //      Source rectangle, or NULL for entire surface
  2937. //  Filter
  2938. //      D3DX_FILTER flags controlling how the image is filtered.
  2939. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2940. //  ColorKey
  2941. //      Color to replace with transparent black, or 0 to disable colorkey.
  2942. //      This is always a 32-bit ARGB color, independent of the source image
  2943. //      format.  Alpha is significant, and should usually be set to FF for
  2944. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  2945. //
  2946. //----------------------------------------------------------------------------
  2947.  
  2948. function D3DXLoadSurfaceFromSurface(
  2949.   pDestSurface: IDirect3DSurface8;
  2950.   pDestPalette: PPaletteEntry;
  2951.   pDestRect: PRect;
  2952.   pSrcSurface: IDirect3DSurface8;
  2953.   pSrcPalette: PPaletteEntry;
  2954.   pSrcRect: PRect;
  2955.   Filter: DWord;
  2956.   ColorKey: TD3DColor): HResult; stdcall; external d3dx8dll;
  2957. {$EXTERNALSYM D3DXLoadSurfaceFromSurface}
  2958.  
  2959.  
  2960.  
  2961. //----------------------------------------------------------------------------
  2962. // D3DXLoadSurfaceFromMemory:
  2963. // ---------------------------
  2964. // Load surface from memory.
  2965. //
  2966. // Parameters:
  2967. //  pDestSurface
  2968. //      Destination surface, which will receive the image.
  2969. //  pDestPalette
  2970. //      Destination palette of 256 colors, or NULL
  2971. //  pDestRect
  2972. //      Destination rectangle, or NULL for entire surface
  2973. //  pSrcMemory
  2974. //      Pointer to the top-left corner of the source image in memory
  2975. //  SrcFormat
  2976. //      Pixel format of the source image.
  2977. //  SrcPitch
  2978. //      Pitch of source image, in bytes.  For DXT formats, this number
  2979. //      should represent the width of one row of cells, in bytes.
  2980. //  pSrcPalette
  2981. //      Source palette of 256 colors, or NULL
  2982. //  pSrcRect
  2983. //      Source rectangle.
  2984. //  Filter
  2985. //      D3DX_FILTER flags controlling how the image is filtered.
  2986. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  2987. //  ColorKey
  2988. //      Color to replace with transparent black, or 0 to disable colorkey.
  2989. //      This is always a 32-bit ARGB color, independent of the source image
  2990. //      format.  Alpha is significant, and should usually be set to FF for
  2991. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  2992. //
  2993. //----------------------------------------------------------------------------
  2994.  
  2995. function D3DXLoadSurfaceFromMemory(
  2996.   pDestSurface: IDirect3DSurface8;
  2997.   pDestPalette: PPaletteEntry;
  2998.   pDestRect: PRect;
  2999.   const pSrcMemory;
  3000.   SrcFormat: TD3DFormat;
  3001.   SrcPitch: LongWord;
  3002.   pSrcPalette: PPaletteEntry;
  3003.   pSrcRect: PRect;
  3004.   Filter: DWord;
  3005.   ColorKey: TD3DColor): HResult; stdcall; external d3dx8dll;
  3006. {$EXTERNALSYM D3DXLoadSurfaceFromMemory}
  3007.  
  3008.  
  3009.  
  3010. //----------------------------------------------------------------------------
  3011. // D3DXSaveSurfaceToFile:
  3012. // ----------------------
  3013. // Save a surface to a image file.
  3014. //
  3015. // Parameters:
  3016. //  pDestFile
  3017. //      File name of the destination file
  3018. //  DestFormat
  3019. //      D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
  3020. //  pSrcSurface
  3021. //      Source surface, containing the image to be saved
  3022. //  pSrcPalette
  3023. //      Source palette of 256 colors, or NULL
  3024. //  pSrcRect
  3025. //      Source rectangle, or NULL for the entire image
  3026. //
  3027. //----------------------------------------------------------------------------
  3028.  
  3029. function D3DXSaveSurfaceToFileA(
  3030.   pDestFile: PAnsiChar;
  3031.   DestFormat: TD3DXImageFileFormat;
  3032.   pSrcSurface: IDirect3DSurface8;
  3033.   pSrcPalette: PPaletteEntry;
  3034.   pSrcRect: PRect): HResult; stdcall; external d3dx8dll name 'D3DXSaveSurfaceToFileA';
  3035. {$EXTERNALSYM D3DXSaveSurfaceToFileA}
  3036.  
  3037. function D3DXSaveSurfaceToFileW(
  3038.   pDestFile: PWideChar;
  3039.   DestFormat: TD3DXImageFileFormat;
  3040.   pSrcSurface: IDirect3DSurface8;
  3041.   pSrcPalette: PPaletteEntry;
  3042.   pSrcRect: PRect): HResult; stdcall; external d3dx8dll name 'D3DXSaveSurfaceToFileW';
  3043. {$EXTERNALSYM D3DXSaveSurfaceToFileW}
  3044.  
  3045. function D3DXSaveSurfaceToFile(
  3046.   pDestFile: PChar;
  3047.   DestFormat: TD3DXImageFileFormat;
  3048.   pSrcSurface: IDirect3DSurface8;
  3049.   pSrcPalette: PPaletteEntry;
  3050.   pSrcRect: PRect): HResult; stdcall; external d3dx8dll name 'D3DXSaveSurfaceToFileA';
  3051. {$EXTERNALSYM D3DXSaveSurfaceToFile}
  3052.  
  3053.  
  3054.  
  3055. //////////////////////////////////////////////////////////////////////////////
  3056. // Load/Save Volume APIs /////////////////////////////////////////////////////
  3057. //////////////////////////////////////////////////////////////////////////////
  3058.  
  3059.  
  3060. //----------------------------------------------------------------------------
  3061. // D3DXLoadVolumeFromFile/Resource:
  3062. // --------------------------------
  3063. // Load volume from a file or resource
  3064. //
  3065. // Parameters:
  3066. //  pDestVolume
  3067. //      Destination volume, which will receive the image.
  3068. //  pDestPalette
  3069. //      Destination palette of 256 colors, or NULL
  3070. //  pDestBox
  3071. //      Destination box, or NULL for entire volume
  3072. //  pSrcFile
  3073. //      File name of the source image.
  3074. //  pSrcModule
  3075. //      Module where resource is located, or NULL for module associated
  3076. //      with image the os used to create the current process.
  3077. //  pSrcResource
  3078. //      Resource name
  3079. //  pSrcData
  3080. //      Pointer to file in memory.
  3081. //  SrcDataSize
  3082. //      Size in bytes of file in memory.
  3083. //  pSrcBox
  3084. //      Source box, or NULL for entire image
  3085. //  Filter
  3086. //      D3DX_FILTER flags controlling how the image is filtered.
  3087. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  3088. //  ColorKey
  3089. //      Color to replace with transparent black, or 0 to disable colorkey.
  3090. //      This is always a 32-bit ARGB color, independent of the source image
  3091. //      format.  Alpha is significant, and should usually be set to FF for
  3092. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  3093. //  pSrcInfo
  3094. //      Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  3095. //      description of the data in the source image file, or NULL.
  3096. //
  3097. //----------------------------------------------------------------------------
  3098.  
  3099. function D3DXLoadVolumeFromFileA(
  3100.   pDestVolume: IDirect3DVolume8;
  3101.   pDestPalette: PPaletteEntry;
  3102.   pDestBox: TD3DBox;
  3103.   pSrcFile: PAnsiChar;
  3104.   pSrcBox: TD3DBox;
  3105.   Filter: DWord;
  3106.   ColorKey: TD3DColor;
  3107.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromFileA';
  3108. {$EXTERNALSYM D3DXLoadVolumeFromFileA}
  3109.  
  3110. function D3DXLoadVolumeFromFileW(
  3111.   pDestVolume: IDirect3DVolume8;
  3112.   pDestPalette: PPaletteEntry;
  3113.   pDestBox: TD3DBox;
  3114.   pSrcFile: PWideChar;
  3115.   pSrcBox: TD3DBox;
  3116.   Filter: DWord;
  3117.   ColorKey: TD3DColor;
  3118.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromFileW';
  3119. {$EXTERNALSYM D3DXLoadVolumeFromFileW}
  3120.  
  3121. function D3DXLoadVolumeFromFile(
  3122.   pDestVolume: IDirect3DVolume8;
  3123.   pDestPalette: PPaletteEntry;
  3124.   pDestBox: TD3DBox;
  3125.   pSrcFile: PChar;
  3126.   pSrcBox: TD3DBox;
  3127.   Filter: DWord;
  3128.   ColorKey: TD3DColor;
  3129.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromFileA';
  3130. {$EXTERNALSYM D3DXLoadVolumeFromFile}
  3131.  
  3132.  
  3133. function D3DXLoadVolumeFromResourceA(
  3134.   pDestVolume: IDirect3DVolume8;
  3135.   pDestPalette: PPaletteEntry;
  3136.   pDestBox: TD3DBox;
  3137.   hSrcModule: HModule;
  3138.   pSrcResource: PAnsiChar;
  3139.   pSrcBox: TD3DBox;
  3140.   Filter: DWord;
  3141.   ColorKey: TD3DColor;
  3142.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromResourceA';
  3143. {$EXTERNALSYM D3DXLoadVolumeFromResourceA}
  3144.  
  3145. function D3DXLoadVolumeFromResourceW(
  3146.   pDestVolume: IDirect3DVolume8;
  3147.   pDestPalette: PPaletteEntry;
  3148.   pDestBox: TD3DBox;
  3149.   hSrcModule: HModule;
  3150.   pSrcResource: PWideChar;
  3151.   pSrcBox: TD3DBox;
  3152.   Filter: DWord;
  3153.   ColorKey: TD3DColor;
  3154.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromResourceW';
  3155. {$EXTERNALSYM D3DXLoadVolumeFromResourceW}
  3156.  
  3157. function D3DXLoadVolumeFromResource(
  3158.   pDestVolume: IDirect3DVolume8;
  3159.   pDestPalette: PPaletteEntry;
  3160.   pDestBox: TD3DBox;
  3161.   hSrcModule: HModule;
  3162.   pSrcResource: PChar;
  3163.   pSrcBox: TD3DBox;
  3164.   Filter: DWord;
  3165.   ColorKey: TD3DColor;
  3166.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll name 'D3DXLoadVolumeFromResourceA';
  3167. {$EXTERNALSYM D3DXLoadVolumeFromResource}
  3168.  
  3169.  
  3170. function D3DXLoadVolumeFromFileInMemory(
  3171.   pDestVolume: IDirect3DVolume8;
  3172.   pDestPalette: PPaletteEntry;
  3173.   pDestBox: TD3DBox;
  3174.   const pSrcData;
  3175.   SrcDataSize: LongWord;
  3176.   pSrcBox: TD3DBox;
  3177.   Filter: DWord;
  3178.   ColorKey: TD3DColor;
  3179.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx8dll;
  3180. {$EXTERNALSYM D3DXLoadVolumeFromFileInMemory}
  3181.  
  3182.  
  3183.  
  3184. //----------------------------------------------------------------------------
  3185. // D3DXLoadVolumeFromVolume:
  3186. // ---------------------------
  3187. // Load volume from another volume (with color conversion)
  3188. //
  3189. // Parameters:
  3190. //  pDestVolume
  3191. //      Destination volume, which will receive the image.
  3192. //  pDestPalette
  3193. //      Destination palette of 256 colors, or NULL
  3194. //  pDestBox
  3195. //      Destination box, or NULL for entire volume
  3196. //  pSrcVolume
  3197. //      Source volume
  3198. //  pSrcPalette
  3199. //      Source palette of 256 colors, or NULL
  3200. //  pSrcBox
  3201. //      Source box, or NULL for entire volume
  3202. //  Filter
  3203. //      D3DX_FILTER flags controlling how the image is filtered.
  3204. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  3205. //  ColorKey
  3206. //      Color to replace with transparent black, or 0 to disable colorkey.
  3207. //      This is always a 32-bit ARGB color, independent of the source image
  3208. //      format.  Alpha is significant, and should usually be set to FF for
  3209. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  3210. //
  3211. //----------------------------------------------------------------------------
  3212.  
  3213. function D3DXLoadVolumeFromVolume(
  3214.   pDestVolume: IDirect3DVolume8;
  3215.   pDestPalette: PPaletteEntry;
  3216.   pDestBox: TD3DBox;
  3217.   pSrcVolume: IDirect3DVolume8;
  3218.   pSrcPalette: PPaletteEntry;
  3219.   pSrcBox: TD3DBox;
  3220.   Filter: DWord;
  3221.   ColorKey: TD3DColor): HResult; stdcall; external d3dx8dll;
  3222. {$EXTERNALSYM D3DXLoadVolumeFromVolume}
  3223.  
  3224.  
  3225.  
  3226. //----------------------------------------------------------------------------
  3227. // D3DXLoadVolumeFromMemory:
  3228. // ---------------------------
  3229. // Load volume from memory.
  3230. //
  3231. // Parameters:
  3232. //  pDestVolume
  3233. //      Destination volume, which will receive the image.
  3234. //  pDestPalette
  3235. //      Destination palette of 256 colors, or NULL
  3236. //  pDestBox
  3237. //      Destination box, or NULL for entire volume
  3238. //  pSrcMemory
  3239. //      Pointer to the top-left corner of the source volume in memory
  3240. //  SrcFormat
  3241. //      Pixel format of the source volume.
  3242. //  SrcRowPitch
  3243. //      Pitch of source image, in bytes.  For DXT formats, this number
  3244. //      should represent the size of one row of cells, in bytes.
  3245. //  SrcSlicePitch
  3246. //      Pitch of source image, in bytes.  For DXT formats, this number
  3247. //      should represent the size of one slice of cells, in bytes.
  3248. //  pSrcPalette
  3249. //      Source palette of 256 colors, or NULL
  3250. //  pSrcBox
  3251. //      Source box.
  3252. //  Filter
  3253. //      D3DX_FILTER flags controlling how the image is filtered.
  3254. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  3255. //  ColorKey
  3256. //      Color to replace with transparent black, or 0 to disable colorkey.
  3257. //      This is always a 32-bit ARGB color, independent of the source image
  3258. //      format.  Alpha is significant, and should usually be set to FF for
  3259. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  3260. //
  3261. //----------------------------------------------------------------------------
  3262.  
  3263. function D3DXLoadVolumeFromMemory(
  3264.   pDestVolume: IDirect3DVolume8;
  3265.   pDestPalette: PPaletteEntry;
  3266.   pDestBox: TD3DBox;
  3267.   const pSrcMemory;
  3268.   SrcFormat: TD3DFormat;
  3269.   SrcRowPitch: LongWord;
  3270.   SrcSlicePitch: LongWord;
  3271.   pSrcPalette: PPaletteEntry;
  3272.   pSrcBox: TD3DBox;
  3273.   Filter: DWord;
  3274.   ColorKey: TD3DColor): HResult; stdcall; external d3dx8dll;
  3275. {$EXTERNALSYM D3DXLoadVolumeFromMemory}
  3276.  
  3277.  
  3278.  
  3279. //----------------------------------------------------------------------------
  3280. // D3DXSaveVolumeToFile:
  3281. // ---------------------
  3282. // Save a volume to a image file.
  3283. //
  3284. // Parameters:
  3285. //  pDestFile
  3286. //      File name of the destination file
  3287. //  DestFormat
  3288. //      D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
  3289. //  pSrcVolume
  3290. //      Source volume, containing the image to be saved
  3291. //  pSrcPalette
  3292. //      Source palette of 256 colors, or NULL
  3293. //  pSrcBox
  3294. //      Source box, or NULL for the entire volume
  3295. //
  3296. //----------------------------------------------------------------------------
  3297.  
  3298. function D3DXSaveVolumeToFileA(
  3299.   pDestFile: PAnsiChar;
  3300.   DestFormat: TD3DXImageFileFormat;
  3301.   pSrcVolume: IDirect3DVolume8;
  3302.   pSrcPalette: PPaletteEntry;
  3303.   pSrcBox: TD3DBox): HResult; stdcall; external d3dx8dll name 'D3DXSaveVolumeToFileA';
  3304. {$EXTERNALSYM D3DXSaveVolumeToFileA}
  3305.  
  3306. function D3DXSaveVolumeToFileW(
  3307.   pDestFile: PWideChar;
  3308.   DestFormat: TD3DXImageFileFormat;
  3309.   pSrcVolume: IDirect3DVolume8;
  3310.   pSrcPalette: PPaletteEntry;
  3311.   pSrcBox: TD3DBox): HResult; stdcall; external d3dx8dll name 'D3DXSaveVolumeToFileW';
  3312. {$EXTERNALSYM D3DXSaveVolumeToFileW}
  3313.  
  3314. function D3DXSaveVolumeToFile(
  3315.   pDestFile: PChar;
  3316.   DestFormat: TD3DXImageFileFormat;
  3317.   pSrcVolume: IDirect3DVolume8;
  3318.   pSrcPalette: PPaletteEntry;
  3319.   pSrcBox: TD3DBox): HResult; stdcall; external d3dx8dll name 'D3DXSaveVolumeToFileA';
  3320. {$EXTERNALSYM D3DXSaveVolumeToFile}
  3321.  
  3322.  
  3323.  
  3324. //////////////////////////////////////////////////////////////////////////////
  3325. // Create/Save Texture APIs //////////////////////////////////////////////////
  3326. //////////////////////////////////////////////////////////////////////////////
  3327.  
  3328.  
  3329. //----------------------------------------------------------------------------
  3330. // D3DXCheckTextureRequirements:
  3331. // -----------------------------
  3332. // Checks texture creation parameters.  If parameters are invalid, this
  3333. // function returns corrected parameters.
  3334. //
  3335. // Parameters:
  3336. //
  3337. //  pDevice
  3338. //      The D3D device to be used
  3339. //  pWidth, pHeight, pDepth, pSize
  3340. //      Desired size in pixels, or NULL.  Returns corrected size.
  3341. //  pNumMipLevels
  3342. //      Number of desired mipmap levels, or NULL.  Returns corrected number.
  3343. //  Usage
  3344. //      Texture usage flags
  3345. //  pFormat
  3346. //      Desired pixel format, or NULL.  Returns corrected format.
  3347. //  Pool
  3348. //      Memory pool to be used to create texture
  3349. //
  3350. //----------------------------------------------------------------------------
  3351. function D3DXCheckTextureRequirements(
  3352.   pDevice: IDirect3DDevice8;
  3353.   pWidth: PLongWord;
  3354.   pHeight: PLongWord;
  3355.   pNumMipLevels: PLongWord;
  3356.   Usage: DWord;
  3357.   pFormat: PD3DFormat;
  3358.   Pool: TD3DPool): HResult; stdcall; external d3dx8dll;
  3359. {$EXTERNALSYM D3DXCheckTextureRequirements}
  3360.  
  3361. function D3DXCheckCubeTextureRequirements(
  3362.   pDevice: IDirect3DDevice8;
  3363.   pSize: PLongWord;
  3364.   pNumMipLevels: PLongWord;
  3365.   Usage: DWord;
  3366.   pFormat: PD3DFormat;
  3367.   Pool: TD3DPool): HResult; stdcall; external d3dx8dll;
  3368. {$EXTERNALSYM D3DXCheckCubeTextureRequirements}
  3369.  
  3370. function D3DXCheckVolumeTextureRequirements(
  3371.   pDevice: IDirect3DDevice8;
  3372.   pWidth: PLongWord;
  3373.   pHeight: PLongWord;
  3374.   pDepth: PLongWord;
  3375.   pNumMipLevels: PLongWord;
  3376.   Usage: DWord;
  3377.   pFormat: PD3DFormat;
  3378.   Pool: TD3DPool): HResult; stdcall; external d3dx8dll;
  3379. {$EXTERNALSYM D3DXCheckVolumeTextureRequirements}
  3380.  
  3381.  
  3382. //----------------------------------------------------------------------------
  3383. // D3DXCreateTexture:
  3384. // ------------------
  3385. // Create an empty texture
  3386. //
  3387. // Parameters:
  3388. //
  3389. //  pDevice
  3390. //      The D3D device with which the texture is going to be used.
  3391. //  Width, Height, Depth, Size
  3392. //      size in pixels; these must be non-zero
  3393. //  MipLevels
  3394. //      number of mip levels desired; if zero or D3DX_DEFAULT, a complete
  3395. //      mipmap chain will be created.
  3396. //  Usage
  3397. //      Texture usage flags
  3398. //  Format
  3399. //      Pixel format.
  3400. //  Pool
  3401. //      Memory pool to be used to create texture
  3402. //  ppTexture, ppCubeTexture, ppVolumeTexture
  3403. //      The texture object that will be created
  3404. //
  3405. //----------------------------------------------------------------------------
  3406.  
  3407. function D3DXCreateTexture(
  3408.   Device: IDirect3DDevice8;
  3409.   Width: LongWord;
  3410.   Height: LongWord;
  3411.   MipLevels: LongWord;
  3412.   Usage: DWord;
  3413.   Format: TD3DFormat;
  3414.   Pool: TD3DPool;
  3415.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll;
  3416. {$EXTERNALSYM D3DXCreateTexture}
  3417.  
  3418. function D3DXCreateCubeTexture(
  3419.   Device: IDirect3DDevice8;
  3420.   Size: LongWord;
  3421.   MipLevels: LongWord;
  3422.   Usage: DWord;
  3423.   Format: TD3DFormat;
  3424.   Pool: TD3DPool;
  3425.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll;
  3426. {$EXTERNALSYM D3DXCreateCubeTexture}
  3427.  
  3428. function D3DXCreateVolumeTexture(
  3429.   Device: IDirect3DDevice8;
  3430.   Width: LongWord;
  3431.   Height: LongWord;
  3432.   Depth: LongWord;
  3433.   MipLevels: LongWord;
  3434.   Usage: DWord;
  3435.   Format: TD3DFormat;
  3436.   Pool: TD3DPool;
  3437.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll;
  3438. {$EXTERNALSYM D3DXCreateVolumeTexture}
  3439.  
  3440.  
  3441.  
  3442. //----------------------------------------------------------------------------
  3443. // D3DXCreateTextureFromFile/Resource:
  3444. // -----------------------------------
  3445. // Create a texture object from a file or resource.
  3446. //
  3447. // Parameters:
  3448. //
  3449. //  pDevice
  3450. //      The D3D device with which the texture is going to be used.
  3451. //  pSrcFile
  3452. //      File name.
  3453. //  hSrcModule
  3454. //      Module handle. if NULL, current module will be used.
  3455. //  pSrcResource
  3456. //      Resource name in module
  3457. //  pvSrcData
  3458. //      Pointer to file in memory.
  3459. //  SrcDataSize
  3460. //      Size in bytes of file in memory.
  3461. //  Width, Height, Depth, Size
  3462. //      Size in pixels; if zero or D3DX_DEFAULT, the size will be taken
  3463. //      from the file.
  3464. //  MipLevels
  3465. //      Number of mip levels;  if zero or D3DX_DEFAULT, a complete mipmap
  3466. //      chain will be created.
  3467. //  Usage
  3468. //      Texture usage flags
  3469. //  Format
  3470. //      Desired pixel format.  If D3DFMT_UNKNOWN, the format will be
  3471. //      taken from the file.
  3472. //  Pool
  3473. //      Memory pool to be used to create texture
  3474. //  Filter
  3475. //      D3DX_FILTER flags controlling how the image is filtered.
  3476. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  3477. //  MipFilter
  3478. //      D3DX_FILTER flags controlling how each miplevel is filtered.
  3479. //      Or D3DX_DEFAULT for D3DX_FILTER_BOX,
  3480. //  ColorKey
  3481. //      Color to replace with transparent black, or 0 to disable colorkey.
  3482. //      This is always a 32-bit ARGB color, independent of the source image
  3483. //      format.  Alpha is significant, and should usually be set to FF for
  3484. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  3485. //  pSrcInfo
  3486. //      Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  3487. //      description of the data in the source image file, or NULL.
  3488. //  pPalette
  3489. //      256 color palette to be filled in, or NULL
  3490. //  ppTexture, ppCubeTexture, ppVolumeTexture
  3491. //      The texture object that will be created
  3492. //
  3493. //----------------------------------------------------------------------------
  3494.  
  3495.  
  3496. // FromFile
  3497.  
  3498. function D3DXCreateTextureFromFileA(
  3499.   Device: IDirect3DDevice8;
  3500.   pSrcFile: PAnsiChar;
  3501.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileA';
  3502. {$EXTERNALSYM D3DXCreateTextureFromFileA}
  3503.  
  3504. function D3DXCreateTextureFromFileW(
  3505.   Device: IDirect3DDevice8;
  3506.   pSrcFile: PWideChar;
  3507.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileW';
  3508. {$EXTERNALSYM D3DXCreateTextureFromFileW}
  3509.  
  3510. function D3DXCreateTextureFromFile(
  3511.   Device: IDirect3DDevice8;
  3512.   pSrcFile: PChar;
  3513.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileA';
  3514. {$EXTERNALSYM D3DXCreateTextureFromFile}
  3515.  
  3516.  
  3517. function D3DXCreateCubeTextureFromFileA(
  3518.   Device: IDirect3DDevice8;
  3519.   pSrcFile: PAnsiChar;
  3520.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileA';
  3521. {$EXTERNALSYM D3DXCreateCubeTextureFromFileA}
  3522.  
  3523. function D3DXCreateCubeTextureFromFileW(
  3524.   Device: IDirect3DDevice8;
  3525.   pSrcFile: PWideChar;
  3526.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileW';
  3527. {$EXTERNALSYM D3DXCreateCubeTextureFromFileW}
  3528.  
  3529. function D3DXCreateCubeTextureFromFile(
  3530.   Device: IDirect3DDevice8;
  3531.   pSrcFile: PChar;
  3532.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileA';
  3533. {$EXTERNALSYM D3DXCreateCubeTextureFromFile}
  3534.  
  3535.  
  3536. function D3DXCreateVolumeTextureFromFileA(
  3537.   Device: IDirect3DDevice8;
  3538.   pSrcFile: PAnsiChar;
  3539.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileA';
  3540. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileA}
  3541.  
  3542. function D3DXCreateVolumeTextureFromFileW(
  3543.   Device: IDirect3DDevice8;
  3544.   pSrcFile: PWideChar;
  3545.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileW';
  3546. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileW}
  3547.  
  3548. function D3DXCreateVolumeTextureFromFile(
  3549.   Device: IDirect3DDevice8;
  3550.   pSrcFile: PChar;
  3551.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileA';
  3552. {$EXTERNALSYM D3DXCreateVolumeTextureFromFile}
  3553.  
  3554.  
  3555. // FromResource
  3556.  
  3557. function D3DXCreateTextureFromResourceA(
  3558.   Device: IDirect3DDevice8;
  3559.   hSrcModule: HModule;
  3560.   pSrcResource: PAnsiChar;
  3561.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceA';
  3562. {$EXTERNALSYM D3DXCreateTextureFromResourceA}
  3563.  
  3564. function D3DXCreateTextureFromResourceW(
  3565.   Device: IDirect3DDevice8;
  3566.   hSrcModule: HModule;
  3567.   pSrcResource: PWideChar;
  3568.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceW';
  3569. {$EXTERNALSYM D3DXCreateTextureFromResourceW}
  3570.  
  3571. function D3DXCreateTextureFromResource(
  3572.   Device: IDirect3DDevice8;
  3573.   hSrcModule: HModule;
  3574.   pSrcResource: PChar;
  3575.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceA';
  3576. {$EXTERNALSYM D3DXCreateTextureFromResource}
  3577.  
  3578.  
  3579. function D3DXCreateCubeTextureFromResourceA(
  3580.   Device: IDirect3DDevice8;
  3581.   hSrcModule: HModule;
  3582.   pSrcResource: PAnsiChar;
  3583.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceA';
  3584. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceA}
  3585.  
  3586. function D3DXCreateCubeTextureFromResourceW(
  3587.   Device: IDirect3DDevice8;
  3588.   hSrcModule: HModule;
  3589.   pSrcResource: PWideChar;
  3590.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceW';
  3591. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceW}
  3592.  
  3593. function D3DXCreateCubeTextureFromResource(
  3594.   Device: IDirect3DDevice8;
  3595.   hSrcModule: HModule;
  3596.   pSrcResource: PChar;
  3597.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceA';
  3598. {$EXTERNALSYM D3DXCreateCubeTextureFromResource}
  3599.  
  3600.  
  3601. function D3DXCreateVolumeTextureFromResourceA(
  3602.   Device: IDirect3DDevice8;
  3603.   hSrcModule: HModule;
  3604.   pSrcResource: PAnsiChar;
  3605.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceA';
  3606. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceA}
  3607.  
  3608. function D3DXCreateVolumeTextureFromResourceW(
  3609.   Device: IDirect3DDevice8;
  3610.   hSrcModule: HModule;
  3611.   pSrcResource: PWideChar;
  3612.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceW';
  3613. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceW}
  3614.  
  3615. function D3DXCreateVolumeTextureFromResource(
  3616.   Device: IDirect3DDevice8;
  3617.   hSrcModule: HModule;
  3618.   pSrcResource: PChar;
  3619.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceA';
  3620. {$EXTERNALSYM D3DXCreateVolumeTextureFromResource}
  3621.  
  3622.  
  3623. // FromFileEx
  3624.  
  3625. function D3DXCreateTextureFromFileExA(
  3626.   Device: IDirect3DDevice8;
  3627.   pSrcFile: PAnsiChar;
  3628.   Width: LongWord;
  3629.   Height: LongWord;
  3630.   MipLevels: LongWord;
  3631.   Usage: DWord;
  3632.   Format: TD3DFormat;
  3633.   Pool: TD3DPool;
  3634.   Filter: DWord;
  3635.   MipFilter: DWord;
  3636.   ColorKey: TD3DColor;
  3637.   pSrcInfo: PD3DXImageInfo;
  3638.   pPalette: PPaletteEntry;
  3639.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileExA';
  3640. {$EXTERNALSYM D3DXCreateTextureFromFileExA}
  3641.  
  3642. function D3DXCreateTextureFromFileExW(
  3643.   Device: IDirect3DDevice8;
  3644.   pSrcFile: PWideChar;
  3645.   Width: LongWord;
  3646.   Height: LongWord;
  3647.   MipLevels: LongWord;
  3648.   Usage: DWord;
  3649.   Format: TD3DFormat;
  3650.   Pool: TD3DPool;
  3651.   Filter: DWord;
  3652.   MipFilter: DWord;
  3653.   ColorKey: TD3DColor;
  3654.   pSrcInfo: PD3DXImageInfo;
  3655.   pPalette: PPaletteEntry;
  3656.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileExW';
  3657. {$EXTERNALSYM D3DXCreateTextureFromFileExW}
  3658.  
  3659. function D3DXCreateTextureFromFileEx(
  3660.   Device: IDirect3DDevice8;
  3661.   pSrcFile: PChar;
  3662.   Width: LongWord;
  3663.   Height: LongWord;
  3664.   MipLevels: LongWord;
  3665.   Usage: DWord;
  3666.   Format: TD3DFormat;
  3667.   Pool: TD3DPool;
  3668.   Filter: DWord;
  3669.   MipFilter: DWord;
  3670.   ColorKey: TD3DColor;
  3671.   pSrcInfo: PD3DXImageInfo;
  3672.   pPalette: PPaletteEntry;
  3673.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromFileExA';
  3674. {$EXTERNALSYM D3DXCreateTextureFromFileEx}
  3675.  
  3676.  
  3677. function D3DXCreateCubeTextureFromFileExA(
  3678.   Device: IDirect3DDevice8;
  3679.   pSrcFile: PAnsiChar;
  3680.   Size: LongWord;
  3681.   MipLevels: LongWord;
  3682.   Usage: DWord;
  3683.   Format: TD3DFormat;
  3684.   Pool: TD3DPool;
  3685.   Filter: DWord;
  3686.   MipFilter: DWord;
  3687.   ColorKey: TD3DColor;
  3688.   pSrcInfo: PD3DXImageInfo;
  3689.   pPalette: PPaletteEntry;
  3690.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileExA';
  3691. {$EXTERNALSYM D3DXCreateCubeTextureFromFileExA}
  3692.  
  3693. function D3DXCreateCubeTextureFromFileExW(
  3694.   Device: IDirect3DDevice8;
  3695.   pSrcFile: PWideChar;
  3696.   Size: LongWord;
  3697.   MipLevels: LongWord;
  3698.   Usage: DWord;
  3699.   Format: TD3DFormat;
  3700.   Pool: TD3DPool;
  3701.   Filter: DWord;
  3702.   MipFilter: DWord;
  3703.   ColorKey: TD3DColor;
  3704.   pSrcInfo: PD3DXImageInfo;
  3705.   pPalette: PPaletteEntry;
  3706.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileExW';
  3707. {$EXTERNALSYM D3DXCreateCubeTextureFromFileExW}
  3708.  
  3709. function D3DXCreateCubeTextureFromFileEx(
  3710.   Device: IDirect3DDevice8;
  3711.   pSrcFile: PChar;
  3712.   Size: LongWord;
  3713.   MipLevels: LongWord;
  3714.   Usage: DWord;
  3715.   Format: TD3DFormat;
  3716.   Pool: TD3DPool;
  3717.   Filter: DWord;
  3718.   MipFilter: DWord;
  3719.   ColorKey: TD3DColor;
  3720.   pSrcInfo: PD3DXImageInfo;
  3721.   pPalette: PPaletteEntry;
  3722.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromFileExA';
  3723. {$EXTERNALSYM D3DXCreateCubeTextureFromFileEx}
  3724.  
  3725.  
  3726. function D3DXCreateVolumeTextureFromFileExA(
  3727.   Device: IDirect3DDevice8;
  3728.   pSrcFile: PAnsiChar;
  3729.   Width: LongWord;
  3730.   Height: LongWord;
  3731.   Depth: LongWord;
  3732.   MipLevels: LongWord;
  3733.   Usage: DWord;
  3734.   Format: TD3DFormat;
  3735.   Pool: TD3DPool;
  3736.   Filter: DWord;
  3737.   MipFilter: DWord;
  3738.   ColorKey: TD3DColor;
  3739.   pSrcInfo: PD3DXImageInfo;
  3740.   pPalette: PPaletteEntry;
  3741.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileExA';
  3742. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileExA}
  3743.  
  3744. function D3DXCreateVolumeTextureFromFileExW(
  3745.   Device: IDirect3DDevice8;
  3746.   pSrcFile: PWideChar;
  3747.   Width: LongWord;
  3748.   Height: LongWord;
  3749.   Depth: LongWord;
  3750.   MipLevels: LongWord;
  3751.   Usage: DWord;
  3752.   Format: TD3DFormat;
  3753.   Pool: TD3DPool;
  3754.   Filter: DWord;
  3755.   MipFilter: DWord;
  3756.   ColorKey: TD3DColor;
  3757.   pSrcInfo: PD3DXImageInfo;
  3758.   pPalette: PPaletteEntry;
  3759.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileExW';
  3760. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileExW}
  3761.  
  3762. function D3DXCreateVolumeTextureFromFileEx(
  3763.   Device: IDirect3DDevice8;
  3764.   pSrcFile: PChar;
  3765.   Width: LongWord;
  3766.   Height: LongWord;
  3767.   Depth: LongWord;
  3768.   MipLevels: LongWord;
  3769.   Usage: DWord;
  3770.   Format: TD3DFormat;
  3771.   Pool: TD3DPool;
  3772.   Filter: DWord;
  3773.   MipFilter: DWord;
  3774.   ColorKey: TD3DColor;
  3775.   pSrcInfo: PD3DXImageInfo;
  3776.   pPalette: PPaletteEntry;
  3777.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromFileExA';
  3778. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileEx}
  3779.  
  3780.  
  3781. // FromResourceEx
  3782.  
  3783. function D3DXCreateTextureFromResourceExA(
  3784.   Device: IDirect3DDevice8;
  3785.   hSrcModule: HModule;
  3786.   pSrcResource: PAnsiChar;
  3787.   Width: LongWord;
  3788.   Height: LongWord;
  3789.   MipLevels: LongWord;
  3790.   Usage: DWord;
  3791.   Format: TD3DFormat;
  3792.   Pool: TD3DPool;
  3793.   Filter: DWord;
  3794.   MipFilter: DWord;
  3795.   ColorKey: TD3DColor;
  3796.   pSrcInfo: PD3DXImageInfo;
  3797.   pPalette: PPaletteEntry;
  3798.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceExA';
  3799. {$EXTERNALSYM D3DXCreateTextureFromResourceExA}
  3800.  
  3801. function D3DXCreateTextureFromResourceExW(
  3802.   Device: IDirect3DDevice8;
  3803.   hSrcModule: HModule;
  3804.   pSrcResource: PWideChar;
  3805.   Width: LongWord;
  3806.   Height: LongWord;
  3807.   MipLevels: LongWord;
  3808.   Usage: DWord;
  3809.   Format: TD3DFormat;
  3810.   Pool: TD3DPool;
  3811.   Filter: DWord;
  3812.   MipFilter: DWord;
  3813.   ColorKey: TD3DColor;
  3814.   pSrcInfo: PD3DXImageInfo;
  3815.   pPalette: PPaletteEntry;
  3816.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceExW';
  3817. {$EXTERNALSYM D3DXCreateTextureFromResourceExW}
  3818.  
  3819. function D3DXCreateTextureFromResourceEx(
  3820.   Device: IDirect3DDevice8;
  3821.   hSrcModule: HModule;
  3822.   pSrcResource: PChar;
  3823.   Width: LongWord;
  3824.   Height: LongWord;
  3825.   MipLevels: LongWord;
  3826.   Usage: DWord;
  3827.   Format: TD3DFormat;
  3828.   Pool: TD3DPool;
  3829.   Filter: DWord;
  3830.   MipFilter: DWord;
  3831.   ColorKey: TD3DColor;
  3832.   pSrcInfo: PD3DXImageInfo;
  3833.   pPalette: PPaletteEntry;
  3834.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateTextureFromResourceExA';
  3835. {$EXTERNALSYM D3DXCreateTextureFromResourceEx}
  3836.  
  3837.  
  3838. function D3DXCreateCubeTextureFromResourceExA(
  3839.   Device: IDirect3DDevice8;
  3840.   hSrcModule: HModule;
  3841.   pSrcResource: PAnsiChar;
  3842.   Size: LongWord;
  3843.   MipLevels: LongWord;
  3844.   Usage: DWord;
  3845.   Format: TD3DFormat;
  3846.   Pool: TD3DPool;
  3847.   Filter: DWord;
  3848.   MipFilter: DWord;
  3849.   ColorKey: TD3DColor;
  3850.   pSrcInfo: PD3DXImageInfo;
  3851.   pPalette: PPaletteEntry;
  3852.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceExA';
  3853. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceExA}
  3854.  
  3855. function D3DXCreateCubeTextureFromResourceExW(
  3856.   Device: IDirect3DDevice8;
  3857.   hSrcModule: HModule;
  3858.   pSrcResource: PWideChar;
  3859.   Size: LongWord;
  3860.   MipLevels: LongWord;
  3861.   Usage: DWord;
  3862.   Format: TD3DFormat;
  3863.   Pool: TD3DPool;
  3864.   Filter: DWord;
  3865.   MipFilter: DWord;
  3866.   ColorKey: TD3DColor;
  3867.   pSrcInfo: PD3DXImageInfo;
  3868.   pPalette: PPaletteEntry;
  3869.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceExW';
  3870. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceExW}
  3871.  
  3872. function D3DXCreateCubeTextureFromResourceEx(
  3873.   Device: IDirect3DDevice8;
  3874.   hSrcModule: HModule;
  3875.   pSrcResource: PChar;
  3876.   Size: LongWord;
  3877.   MipLevels: LongWord;
  3878.   Usage: DWord;
  3879.   Format: TD3DFormat;
  3880.   Pool: TD3DPool;
  3881.   Filter: DWord;
  3882.   MipFilter: DWord;
  3883.   ColorKey: TD3DColor;
  3884.   pSrcInfo: PD3DXImageInfo;
  3885.   pPalette: PPaletteEntry;
  3886.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateCubeTextureFromResourceExA';
  3887. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceEx}
  3888.  
  3889.  
  3890. function D3DXCreateVolumeTextureFromResourceExA(
  3891.   Device: IDirect3DDevice8;
  3892.   hSrcModule: HModule;
  3893.   pSrcResource: PAnsiChar;
  3894.   Width: LongWord;
  3895.   Height: LongWord;
  3896.   Depth: LongWord;
  3897.   MipLevels: LongWord;
  3898.   Usage: DWord;
  3899.   Format: TD3DFormat;
  3900.   Pool: TD3DPool;
  3901.   Filter: DWord;
  3902.   MipFilter: DWord;
  3903.   ColorKey: TD3DColor;
  3904.   pSrcInfo: PD3DXImageInfo;
  3905.   pPalette: PPaletteEntry;
  3906.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceExA';
  3907. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceExA}
  3908.  
  3909. function D3DXCreateVolumeTextureFromResourceExW(
  3910.   Device: IDirect3DDevice8;
  3911.   hSrcModule: HModule;
  3912.   pSrcResource: PWideChar;
  3913.   Width: LongWord;
  3914.   Height: LongWord;
  3915.   Depth: LongWord;
  3916.   MipLevels: LongWord;
  3917.   Usage: DWord;
  3918.   Format: TD3DFormat;
  3919.   Pool: TD3DPool;
  3920.   Filter: DWord;
  3921.   MipFilter: DWord;
  3922.   ColorKey: TD3DColor;
  3923.   pSrcInfo: PD3DXImageInfo;
  3924.   pPalette: PPaletteEntry;
  3925.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceExW';
  3926. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceExW}
  3927.  
  3928. function D3DXCreateVolumeTextureFromResourceEx(
  3929.   Device: IDirect3DDevice8;
  3930.   hSrcModule: HModule;
  3931.   pSrcResource: PChar;
  3932.   Width: LongWord;
  3933.   Height: LongWord;
  3934.   Depth: LongWord;
  3935.   MipLevels: LongWord;
  3936.   Usage: DWord;
  3937.   Format: TD3DFormat;
  3938.   Pool: TD3DPool;
  3939.   Filter: DWord;
  3940.   MipFilter: DWord;
  3941.   ColorKey: TD3DColor;
  3942.   pSrcInfo: PD3DXImageInfo;
  3943.   pPalette: PPaletteEntry;
  3944.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll name 'D3DXCreateVolumeTextureFromResourceExA';
  3945. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceEx}
  3946.  
  3947.  
  3948. // FromFileInMemory
  3949.  
  3950. function D3DXCreateTextureFromFileInMemory(
  3951.   Device: IDirect3DDevice8;
  3952.   const pSrcData;
  3953.   SrcDataSize: LongWord;
  3954.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll;
  3955. {$EXTERNALSYM D3DXCreateTextureFromFileInMemory}
  3956.  
  3957. function D3DXCreateCubeTextureFromFileInMemory(
  3958.   Device: IDirect3DDevice8;
  3959.   const pSrcData;
  3960.   SrcDataSize: LongWord;
  3961.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll;
  3962. {$EXTERNALSYM D3DXCreateCubeTextureFromFileInMemory}
  3963.  
  3964. function D3DXCreateVolumeTextureFromFileInMemory(
  3965.   Device: IDirect3DDevice8;
  3966.   const pSrcData;
  3967.   SrcDataSize: LongWord;
  3968.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll;
  3969. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileInMemory}
  3970.  
  3971.  
  3972. // FromFileInMemoryEx
  3973.  
  3974. function D3DXCreateTextureFromFileInMemoryEx(
  3975.   Device: IDirect3DDevice8;
  3976.   const pSrcData;
  3977.   SrcDataSize: LongWord;
  3978.   Width: LongWord;
  3979.   Height: LongWord;
  3980.   MipLevels: LongWord;
  3981.   Usage: DWord;
  3982.   Format: TD3DFormat;
  3983.   Pool: TD3DPool;
  3984.   Filter: DWord;
  3985.   MipFilter: DWord;
  3986.   ColorKey: TD3DColor;
  3987.   pSrcInfo: PD3DXImageInfo;
  3988.   pPalette: PPaletteEntry;
  3989.   out ppTexture: IDirect3DTexture8): HResult; stdcall; external d3dx8dll;
  3990. {$EXTERNALSYM D3DXCreateTextureFromFileInMemoryEx}
  3991.  
  3992. function D3DXCreateCubeTextureFromFileInMemoryEx(
  3993.   Device: IDirect3DDevice8;
  3994.   const pSrcData;
  3995.   SrcDataSize: LongWord;
  3996.   Size: LongWord;
  3997.   MipLevels: LongWord;
  3998.   Usage: DWord;
  3999.   Format: TD3DFormat;
  4000.   Pool: TD3DPool;
  4001.   Filter: DWord;
  4002.   MipFilter: DWord;
  4003.   ColorKey: TD3DColor;
  4004.   pSrcInfo: PD3DXImageInfo;
  4005.   pPalette: PPaletteEntry;
  4006.   out ppCubeTexture: IDirect3DCubeTexture8): HResult; stdcall; external d3dx8dll;
  4007. {$EXTERNALSYM D3DXCreateCubeTextureFromFileInMemoryEx}
  4008.  
  4009. function D3DXCreateVolumeTextureFromFileInMemoryEx(
  4010.   Device: IDirect3DDevice8;
  4011.   const pSrcData;
  4012.   SrcDataSize: LongWord;
  4013.   Width: LongWord;
  4014.   Height: LongWord;
  4015.   Depth: LongWord;
  4016.   MipLevels: LongWord;
  4017.   Usage: DWord;
  4018.   Format: TD3DFormat;
  4019.   Pool: TD3DPool;
  4020.   Filter: DWord;
  4021.   MipFilter: DWord;
  4022.   ColorKey: TD3DColor;
  4023.   pSrcInfo: PD3DXImageInfo;
  4024.   pPalette: PPaletteEntry;
  4025.   out ppVolumeTexture: IDirect3DVolumeTexture8): HResult; stdcall; external d3dx8dll;
  4026. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileInMemoryEx}
  4027.  
  4028.  
  4029.  
  4030. //----------------------------------------------------------------------------
  4031. // D3DXSaveTextureToFile:
  4032. // ----------------------
  4033. // Save a texture to a file.
  4034. //
  4035. // Parameters:
  4036. //  pDestFile
  4037. //      File name of the destination file
  4038. //  DestFormat
  4039. //      D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
  4040. //  pSrcTexture
  4041. //      Source texture, containing the image to be saved
  4042. //  pSrcPalette
  4043. //      Source palette of 256 colors, or NULL
  4044. //
  4045. //----------------------------------------------------------------------------
  4046.  
  4047.  
  4048. function D3DXSaveTextureToFileA(
  4049.   pDestFile: PAnsiChar;
  4050.   DestFormat: TD3DXImageFileFormat;
  4051.   pSrcTexture: IDirect3DBaseTexture8;
  4052.   pSrcPalette: PPaletteEntry): HResult; stdcall; external d3dx8dll name 'D3DXSaveTextureToFileA';
  4053. {$EXTERNALSYM D3DXSaveTextureToFileA}
  4054.  
  4055. function D3DXSaveTextureToFileW(
  4056.   pDestFile: PWideChar;
  4057.   DestFormat: TD3DXImageFileFormat;
  4058.   pSrcTexture: IDirect3DBaseTexture8;
  4059.   pSrcPalette: PPaletteEntry): HResult; stdcall; external d3dx8dll name 'D3DXSaveTextureToFileW';
  4060. {$EXTERNALSYM D3DXSaveTextureToFileW}
  4061.  
  4062. function D3DXSaveTextureToFile(
  4063.   pDestFile: PChar;
  4064.   DestFormat: TD3DXImageFileFormat;
  4065.   pSrcTexture: IDirect3DBaseTexture8;
  4066.   pSrcPalette: PPaletteEntry): HResult; stdcall; external d3dx8dll name 'D3DXSaveTextureToFileA';
  4067. {$EXTERNALSYM D3DXSaveTextureToFile}
  4068.  
  4069.  
  4070.  
  4071.  
  4072. //////////////////////////////////////////////////////////////////////////////
  4073. // Misc Texture APIs /////////////////////////////////////////////////////////
  4074. //////////////////////////////////////////////////////////////////////////////
  4075.  
  4076. //----------------------------------------------------------------------------
  4077. // D3DXFilterTexture:
  4078. // ------------------
  4079. // Filters mipmaps levels of a texture.
  4080. //
  4081. // Parameters:
  4082. //  pBaseTexture
  4083. //      The texture object to be filtered
  4084. //  pPalette
  4085. //      256 color palette to be used, or NULL for non-palettized formats
  4086. //  SrcLevel
  4087. //      The level whose image is used to generate the subsequent levels.
  4088. //  Filter
  4089. //      D3DX_FILTER flags controlling how each miplevel is filtered.
  4090. //      Or D3DX_DEFAULT for D3DX_FILTER_BOX,
  4091. //
  4092. //-------------------------------------------------------------------------
  4093.  
  4094. function D3DXFilterTexture(
  4095.   pTexture: IDirect3DTexture8;
  4096.   pPalette: PPaletteEntry;
  4097.   SrcLevel: LongWord;
  4098.   Filter: DWord): HResult; stdcall; external d3dx8dll;
  4099. {$EXTERNALSYM D3DXFilterTexture}
  4100.  
  4101. // #define D3DXFilterCubeTexture D3DXFilterTexture
  4102. // In Pascal this mapped to DLL-exported "D3DXFilterTexture" function
  4103. function D3DXFilterCubeTexture(
  4104.   pTexture: IDirect3DCubeTexture8;
  4105.   pPalette: PPaletteEntry;
  4106.   SrcLevel: LongWord;
  4107.   Filter: DWord): HResult; stdcall; external d3dx8dll name 'D3DXFilterTexture';
  4108. {$EXTERNALSYM D3DXFilterCubeTexture}
  4109.  
  4110. // #define D3DXFilterVolumeTexture D3DXFilterTexture
  4111. // In Pascal this mapped to DLL-exported "D3DXFilterTexture" function
  4112. function D3DXFilterVolumeTexture(
  4113.   pTexture: IDirect3DVolumeTexture8;
  4114.   pPalette: PPaletteEntry;
  4115.   SrcLevel: LongWord;
  4116.   Filter: DWord): HResult; stdcall; external d3dx8dll name 'D3DXFilterTexture';
  4117. {$EXTERNALSYM D3DXFilterVolumeTexture}
  4118.  
  4119.  
  4120.  
  4121. //----------------------------------------------------------------------------
  4122. // D3DXFillTexture:
  4123. // ----------------
  4124. // Uses a user provided function to fill each texel of each mip level of a
  4125. // given texture.
  4126. //
  4127. // Paramters:
  4128. //  pTexture, pCubeTexture, pVolumeTexture
  4129. //      Pointer to the texture to be filled.
  4130. //  pFunction
  4131. //      Pointer to user provided evalutor function which will be used to
  4132. //      compute the value of each texel.
  4133. //  pData
  4134. //      Pointer to an arbitrary block of user defined data.  This pointer
  4135. //      will be passed to the function provided in pFunction
  4136. //-----------------------------------------------------------------------------
  4137.  
  4138. function D3DXFillTexture(
  4139.   pTexture: IDirect3DTexture8;
  4140.   pFunction: TD3DXFill2D;
  4141.   const pData): HResult; stdcall; external d3dx8dll;
  4142. {$EXTERNALSYM D3DXFillTexture}
  4143.  
  4144. function D3DXFillCubeTexture(
  4145.   pCubeTexture: IDirect3DCubeTexture8;
  4146.   pFunction: TD3DXFill2D;
  4147.   const pData): HResult; stdcall; external d3dx8dll;
  4148. {$EXTERNALSYM D3DXFillCubeTexture}
  4149.  
  4150. function D3DXFillVolumeTexture(
  4151.   pVolumeTexture: IDirect3DVolumeTexture8;
  4152.   pFunction: TD3DXFill3D;
  4153.   const pData): HResult; stdcall; external d3dx8dll;
  4154. {$EXTERNALSYM D3DXFillVolumeTexture}
  4155.  
  4156.  
  4157.  
  4158. //----------------------------------------------------------------------------
  4159. // D3DXComputeNormalMap:
  4160. // ---------------------
  4161. // Converts a height map into a normal map.  The (x,y,z) components of each
  4162. // normal are mapped to the (r,g,b) channels of the output texture.
  4163. //
  4164. // Parameters
  4165. //  pTexture
  4166. //      Pointer to the destination texture
  4167. //  pSrcTexture
  4168. //      Pointer to the source heightmap texture
  4169. //  pSrcPalette
  4170. //      Source palette of 256 colors, or NULL
  4171. //  Flags
  4172. //      D3DX_NORMALMAP flags
  4173. //  Channel
  4174. //      D3DX_CHANNEL specifying source of height information
  4175. //  Amplitude
  4176. //      The constant value which the height information is multiplied by.
  4177. //---------------------------------------------------------------------------
  4178.  
  4179. function D3DXComputeNormalMap(
  4180.   pTexture: IDirect3DTexture8;
  4181.   pSrcTexture: IDirect3DTexture8;
  4182.   pSrcPalette: PPaletteEntry;
  4183.   Flags: DWord;
  4184.   Channel: DWord;
  4185.   Amplitude: Single): HResult; stdcall; external d3dx8dll;
  4186. {$EXTERNALSYM D3DXComputeNormalMap}
  4187.  
  4188.  
  4189.  
  4190. //********************************************************************
  4191. // Introduced types for compatibility with "REVISED" D3DX8.pas translation
  4192. // by Ampaze (Tim Baumgarten) from www.Delphi-Jedi.org/DelphiGraphics
  4193. type
  4194.   PD3DXEffect_Desc      = PD3DXEffectDesc;
  4195.   PD3DXImage_Info       = PD3DXImageInfo;
  4196.   PD3DXParameter_Desc   = PD3DXParameterDesc;
  4197.   PD3DXPass_Desc        = PD3DXPassDesc;
  4198.   PD3DXRTE_Desc         = PD3DXRTEDesc;
  4199.   PD3DXRTS_Desc         = PD3DXRTSDesc;
  4200.   PD3DXTechnique_Desc   = PD3DXTechniqueDesc;
  4201.  
  4202.   TD3DXEffect_Desc      = TD3DXEffectDesc;
  4203.   TD3DXImage_Info       = TD3DXImageInfo;
  4204.   TD3DXParameter_Desc   = TD3DXParameterDesc;
  4205.   TD3DXPass_Desc        = TD3DXPassDesc;
  4206.   TD3DXRTE_Desc         = TD3DXRTEDesc;
  4207.   TD3DXRTS_Desc         = TD3DXRTSDesc;
  4208.   TD3DXTechnique_Desc   = TD3DXTechniqueDesc;
  4209.  
  4210.   PD3DXImage_FileFormat = PD3DXImageFileFormat;
  4211.   TD3DXImage_FileFormat = TD3DXImageFileFormat;
  4212.  
  4213. (*$HPPEMIT '}  /* namespace D3dx8 */' *)
  4214.  
  4215. //***************************************************************************//
  4216. //***************************************************************************//
  4217. //***************************************************************************//
  4218. implementation
  4219. //***************************************************************************//
  4220. //***************************************************************************//
  4221. //***************************************************************************//
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228. //////////////////////////////////////////////////////////////////////////////
  4229. //
  4230. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  4231. //
  4232. //  File:       d3dx8math.h
  4233. //  Content:    D3DX math types and functions
  4234. //
  4235. //////////////////////////////////////////////////////////////////////////////
  4236.  
  4237.  
  4238.  
  4239. //===========================================================================
  4240. //
  4241. // General purpose utilities
  4242. //
  4243. //===========================================================================
  4244.  
  4245.  
  4246. function D3DXToRadian(Degree: Single): Single;
  4247. begin
  4248.   Result:= Degree * (D3DX_PI / 180.0);
  4249. end;
  4250.  
  4251. function D3DXToDegree(Radian: Single): Single;
  4252. begin
  4253.   Result:= Radian * (180.0 / D3DX_PI);
  4254. end;
  4255.  
  4256.  
  4257. //--------------------------
  4258. // 2D Vector
  4259. //--------------------------
  4260.  
  4261. function D3DXVector2(_x, _y: Single): TD3DXVector2;
  4262. begin
  4263.   Result.x:= _x; Result.y:= _y;
  4264. end;
  4265.  
  4266. function D3DXVector2Equal(const v1, v2: TD3DXVector2): Boolean;
  4267. begin
  4268.   Result:= (v1.x = v2.x) and (v1.y = v2.y);
  4269. end;
  4270.  
  4271.  
  4272. //--------------------------
  4273. // 3D Vector
  4274. //--------------------------
  4275. function D3DXVector3(_x, _y, _z: Single): TD3DXVector3;
  4276. begin
  4277.   Result.x:= _x; Result.y:= _y; Result.z:=_z;
  4278. end;
  4279.  
  4280. function D3DXVector3Equal(const v1, v2: TD3DXVector3): Boolean;
  4281. begin
  4282.   Result:= (v1.x = v2.x) and (v1.y = v2.y) and (v1.z = v2.z);
  4283. end;
  4284.  
  4285.  
  4286. //--------------------------
  4287. // 4D Vector
  4288. //--------------------------
  4289.  
  4290. function D3DXVector4(_x, _y, _z, _w: Single): TD3DXVector4;
  4291. begin
  4292.   with Result do
  4293.   begin
  4294.     x:= _x; y:= _y; z:= _z; w:= _w;
  4295.   end;
  4296. end;
  4297.  
  4298. function D3DXVector4Equal(const v1, v2: TD3DXVector4): Boolean;
  4299. begin
  4300.   Result:= (v1.x = v2.x) and (v1.y = v2.y) and
  4301.     (v1.z = v2.z) and (v1.w = v2.w);
  4302. end;
  4303.  
  4304.  
  4305. //--------------------------
  4306. // 4D Matrix
  4307. //--------------------------
  4308. function D3DXMatrix(
  4309.   _m00, _m01, _m02, _m03,
  4310.   _m10, _m11, _m12, _m13,
  4311.   _m20, _m21, _m22, _m23,
  4312.   _m30, _m31, _m32, _m33: Single): TD3DXMatrix;
  4313. begin
  4314.   with Result do
  4315.   begin
  4316.     m[0,0]:= _m00; m[0,1]:= _m01; m[0,2]:= _m02; m[0,3]:= _m03;
  4317.     m[1,0]:= _m10; m[1,1]:= _m11; m[1,2]:= _m12; m[1,3]:= _m13;
  4318.     m[2,0]:= _m20; m[2,1]:= _m21; m[2,2]:= _m22; m[2,3]:= _m23;
  4319.     m[3,0]:= _m30; m[3,1]:= _m31; m[3,2]:= _m32; m[3,3]:= _m33;
  4320.   end;
  4321. end;
  4322.  
  4323. function D3DXMatrixAdd(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  4324. var
  4325.   pOut, p1, p2: PSingle; x: Integer;
  4326. begin
  4327.   pOut:= @mOut._11; p1:= @m1._11; p2:= @m2._11;
  4328.   for x:= 0 to 15 do
  4329.   begin
  4330.     pOut^:= p1^+p2^;
  4331.     Inc(pOut); Inc(p1); Inc(p2);
  4332.   end;
  4333.   Result:= @mOut;
  4334. end;
  4335.  
  4336. function D3DXMatrixSubtract(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  4337. var
  4338.   pOut, p1, p2: PSingle; x: Integer;
  4339. begin
  4340.   pOut:= @mOut._11; p1:= @m1._11; p2:= @m2._11;
  4341.   for x:= 0 to 15 do
  4342.   begin
  4343.     pOut^:= p1^-p2^;
  4344.     Inc(pOut); Inc(p1); Inc(p2);
  4345.   end;
  4346.   Result:= @mOut;
  4347. end;
  4348.  
  4349. function D3DXMatrixMul(out mOut: TD3DXMatrix; const m: TD3DXMatrix; MulBy: Single): PD3DXMatrix;
  4350. var
  4351.   pOut, p: PSingle; x: Integer;
  4352. begin
  4353.   pOut:= @mOut._11; p:= @m._11;
  4354.   for x:= 0 to 15 do
  4355.   begin
  4356.     pOut^:= p^* MulBy;
  4357.     Inc(pOut); Inc(p);
  4358.   end;
  4359.   Result:= @mOut;
  4360. end;
  4361.  
  4362. function D3DXMatrixEqual(const m1, m2: TD3DXMatrix): Boolean;
  4363. begin
  4364.   Result:= CompareMem(@m1, @m2, SizeOf(TD3DXMatrix));
  4365. end;
  4366.  
  4367. //--------------------------
  4368. // Quaternion
  4369. //--------------------------
  4370. function D3DXQuaternion(_x, _y, _z, _w: Single): TD3DXQuaternion;
  4371. begin
  4372.   with Result do
  4373.   begin
  4374.     x:= _x; y:= _y; z:= _z; w:= _w;
  4375.   end;
  4376. end;
  4377.  
  4378. function D3DXQuaternionAdd(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  4379. begin
  4380.   with Result do
  4381.   begin
  4382.     x:= q1.x+q2.x; y:= q1.y+q2.y; z:= q1.z+q2.z; w:= q1.w+q2.w;
  4383.   end;
  4384. end;
  4385.  
  4386. function D3DXQuaternionSubtract(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  4387. begin
  4388.   with Result do
  4389.   begin
  4390.     x:= q1.x-q2.x; y:= q1.y-q2.y; z:= q1.z-q2.z; w:= q1.w-q2.w;
  4391.   end;
  4392. end;
  4393.  
  4394. function D3DXQuaternionEqual(const q1, q2: TD3DXQuaternion): Boolean;
  4395. begin
  4396.   Result:= (q1.x = q2.x) and (q1.y = q2.y) and
  4397.     (q1.z = q2.z) and (q1.w = q2.w);
  4398. end;
  4399.  
  4400. function D3DXQuaternionScale(out qOut: TD3DXQuaternion; const q: TD3DXQuaternion;
  4401.   s: Single): PD3DXQuaternion;
  4402. begin
  4403.   with qOut do
  4404.   begin
  4405.     x:= q.x*s; y:= q.y*s; z:= q.z*s; w:= q.w*s;
  4406.   end;
  4407.   Result:= @qOut;
  4408. end;
  4409.  
  4410.  
  4411. //--------------------------
  4412. // Plane
  4413. //--------------------------
  4414.  
  4415. function D3DXPlane(_a, _b, _c, _d: Single): TD3DXPlane;
  4416. begin
  4417.   with Result do
  4418.   begin
  4419.     a:= _a; b:= _b; c:= _c; d:= _d;
  4420.   end;
  4421. end;
  4422.  
  4423. function D3DXPlaneEqual(const p1, p2: TD3DXPlane): Boolean;
  4424. begin
  4425.   Result:=
  4426.     (p1.a = p2.a) and (p1.b = p2.b) and
  4427.     (p1.c = p2.c) and (p1.d = p2.d);
  4428. end;
  4429.  
  4430.  
  4431. //--------------------------
  4432. // Color
  4433. //--------------------------
  4434.  
  4435. function D3DXColor(_r, _g, _b, _a: Single): TD3DXColor;
  4436. begin
  4437.   with Result do
  4438.   begin
  4439.     r:= _r; g:= _g; b:= _b; a:= _a;
  4440.   end;
  4441. end;
  4442.  
  4443. function D3DXColorToDWord(c: TD3DXColor): DWord;
  4444.  
  4445.   function ColorLimit(const x: Single): DWord;
  4446.   begin
  4447.     if x > 1.0 then Result:= 255
  4448.      else if x < 0 then Result:= 0
  4449.       else Result:= Trunc(x * 255.0 + 0.5);
  4450.   end;
  4451. begin
  4452.   Result:= ColorLimit(c.a) shl 24 or ColorLimit(c.r) shl 16
  4453.     or ColorLimit(c.g) shl 8 or ColorLimit(c.b);
  4454. end;
  4455.  
  4456. function D3DXColorFromDWord(c: DWord): TD3DXColor;
  4457. const
  4458.   f: Single = 1/255;
  4459. begin
  4460.   with Result do
  4461.   begin
  4462.     r:= f * Byte(c shr 16);
  4463.     g:= f * Byte(c shr  8);
  4464.     b:= f * Byte(c shr  0);
  4465.     a:= f * Byte(c shr 24);
  4466.   end;
  4467. end;
  4468.  
  4469. function D3DXColorEqual(const c1, c2: TD3DXColor): Boolean;
  4470. begin
  4471.   Result:= (c1.r = c2.r) and (c1.g = c2.g) and (c1.b = c2.b) and (c1.a = c2.a);
  4472. end;
  4473.  
  4474.  
  4475. //===========================================================================
  4476. //
  4477. // D3DX math functions:
  4478. //
  4479. // NOTE:
  4480. //  * All these functions can take the same object as in and out parameters.
  4481. //
  4482. //  * Out parameters are typically also returned as return values, so that
  4483. //    the output of one function may be used as a parameter to another.
  4484. //
  4485. //===========================================================================
  4486.  
  4487. //--------------------------
  4488. // 2D Vector
  4489. //--------------------------
  4490.  
  4491. // "inline"
  4492. function D3DXVec2Length(const v: TD3DXVector2): Single;
  4493. begin
  4494.   with v do Result:= Sqrt(x*x + y*y);
  4495. end;
  4496.  
  4497. function D3DXVec2LengthSq(const v: TD3DXVector2): Single;
  4498. begin
  4499.   with v do Result:= x*x + y*y;
  4500. end;
  4501.  
  4502. function D3DXVec2Dot(const v1, v2: TD3DXVector2): Single;
  4503. begin
  4504.   Result:= v1.x*v2.x + v1.y*v2.y;
  4505. end;
  4506.  
  4507. // Z component of ((x1,y1,0) cross (x2,y2,0))
  4508. function D3DXVec2CCW(const v1, v2: TD3DXVector2): Single;
  4509. begin
  4510.   Result:= v1.x*v2.y - v1.y*v2.x;
  4511. end;
  4512.  
  4513. function D3DXVec2Add(const v1, v2: TD3DXVector2): TD3DXVector2;
  4514. begin
  4515.   Result.x:= v1.x + v2.x;
  4516.   Result.y:= v1.y + v2.y;
  4517. end;
  4518.  
  4519. function D3DXVec2Subtract(const v1, v2: TD3DXVector2): TD3DXVector2;
  4520. begin
  4521.   Result.x:= v1.x - v2.x;
  4522.   Result.y:= v1.y - v2.y;
  4523. end;
  4524.  
  4525. // Minimize each component.  x = min(x1, x2), y = min(y1, y2)
  4526. function D3DXVec2Minimize(out vOut: TD3DXVector2; const v1, v2: TD3DXVEctor2): PD3DXVector2;
  4527. begin
  4528.   if v1.x < v2.x then vOut.x:= v1.x else vOut.y:= v2.x;
  4529.   if v1.y < v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  4530.   Result:= @vOut;
  4531. end;
  4532.  
  4533. // Maximize each component.  x = max(x1, x2), y = max(y1, y2)
  4534. function D3DXVec2Maximize(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2): PD3DXVector2;
  4535. begin
  4536.   if v1.x > v2.x then vOut.x:= v1.x else vOut.y:= v2.x;
  4537.   if v1.y > v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  4538.   Result:= @vOut;
  4539. end;
  4540.  
  4541. function D3DXVec2Scale(out vOut: TD3DXVector2; const v: TD3DXVector2; s: Single): PD3DXVector2;
  4542. begin
  4543.   vOut.x:= v.x*s; vOut.y:= v.y*s;
  4544.   Result:= @vOut;
  4545. end;
  4546.  
  4547. // Linear interpolation. V1 + s(V2-V1)
  4548. function D3DXVec2Lerp(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2; s: Single): PD3DXVector2;
  4549. begin
  4550.   vOut.x:= v1.x + s * (v2.x-v1.x);
  4551.   vOut.y:= v1.y + s * (v2.y-v1.y);
  4552.   Result:= @vOut;
  4553. end;
  4554.  
  4555.  
  4556. //--------------------------
  4557. // 3D Vector
  4558. //--------------------------
  4559. function D3DXVec3Length(const v: TD3DXVector3): Single;
  4560. begin
  4561.   with v do Result:= Sqrt(x*x + y*y + z*z);
  4562. end;
  4563.  
  4564. function D3DXVec3LengthSq(const v: TD3DXVector3): Single;
  4565. begin
  4566.   with v do Result:= x*x + y*y + z*z;
  4567. end;
  4568.  
  4569. function D3DXVec3Dot(const v1, v2: TD3DXVector3): Single;
  4570. begin
  4571.   Result:= v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  4572. end;
  4573.  
  4574. function D3DXVec3Cross(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  4575. begin
  4576.   vOut.x:= v1.y * v2.z - v1.z * v2.y;
  4577.   vOut.y:= v1.z * v2.x - v1.x * v2.z;
  4578.   vOut.z:= v1.x * v2.y - v1.y * v2.x;
  4579.   Result:= @vOut;
  4580. end;
  4581.  
  4582. function D3DXVec3Add(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  4583. begin
  4584.   with vOut do
  4585.   begin
  4586.     x:= v1.x + v2.x;
  4587.     y:= v1.y + v2.y;
  4588.     z:= v1.z + v2.z;
  4589.   end;
  4590.   Result:= @vOut;
  4591. end;
  4592.  
  4593. function D3DXVec3Subtract(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  4594. begin
  4595.   with vOut do
  4596.   begin
  4597.     x:= v1.x - v2.x;
  4598.     y:= v1.y - v2.y;
  4599.     z:= v1.z - v2.z;
  4600.   end;
  4601.   Result:= @vOut;
  4602. end;
  4603.  
  4604. // Minimize each component.  x = min(x1, x2), y = min(y1, y2)
  4605. function D3DXVec3Minimize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  4606. begin
  4607.   if v1.x < v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  4608.   if v1.y < v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  4609.   if v1.z < v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  4610.   Result:= @vOut;
  4611. end;
  4612.  
  4613. // Maximize each component.  x = max(x1, x2), y = max(y1, y2)
  4614. function D3DXVec3Maximize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  4615. begin
  4616.   if v1.x > v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  4617.   if v1.y > v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  4618.   if v1.z > v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  4619.   Result:= @vOut;
  4620. end;
  4621.  
  4622. function D3DXVec3Scale(out vOut: TD3DXVector3; const v: TD3DXVector3; s: Single): PD3DXVector3;
  4623. begin
  4624.   with vOut do
  4625.   begin
  4626.     x:= v.x * s; y:= v.y * s; z:= v.z * s;
  4627.   end;
  4628.   Result:= @vOut;
  4629. end;
  4630.  
  4631. // Linear interpolation. V1 + s(V2-V1)
  4632. function D3DXVec3Lerp(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3; s: Single): PD3DXVector3;
  4633. begin
  4634.   vOut.x:= v1.x + s * (v2.x-v1.x);
  4635.   vOut.y:= v1.y + s * (v2.y-v1.y);
  4636.   vOut.z:= v1.z + s * (v2.z-v1.z);
  4637.   Result:= @vOut;
  4638. end;
  4639.  
  4640.  
  4641. //--------------------------
  4642. // 4D Vector
  4643. //--------------------------
  4644.  
  4645. function D3DXVec4Length(const v: TD3DXVector4): Single;
  4646. begin
  4647.   with v do Result:= Sqrt(x*x + y*y + z*z + w*w);
  4648. end;
  4649.  
  4650. function D3DXVec4LengthSq(const v: TD3DXVector4): Single;
  4651. begin
  4652.   with v do Result:= x*x + y*y + z*z + w*w
  4653. end;
  4654.  
  4655. function D3DXVec4Dot(const v1, v2: TD3DXVector4): Single;
  4656. begin
  4657.   Result:= v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;
  4658. end;
  4659.  
  4660. function D3DXVec4Add(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  4661. begin
  4662.   with vOut do
  4663.   begin
  4664.     x:= v1.x + v2.x;
  4665.     y:= v1.y + v2.y;
  4666.     z:= v1.z + v2.z;
  4667.     w:= v1.w + v2.w;
  4668.   end;
  4669.   Result:= @vOut;
  4670. end;
  4671.  
  4672. function D3DXVec4Subtract(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  4673. begin
  4674.   with vOut do
  4675.   begin
  4676.     x:= v1.x - v2.x;
  4677.     y:= v1.y - v2.y;
  4678.     z:= v1.z - v2.z;
  4679.     w:= v1.w - v2.w;
  4680.   end;
  4681.   Result:= @vOut;
  4682. end;
  4683.  
  4684.  
  4685. // Minimize each component.  x = min(x1, x2), y = min(y1, y2)
  4686. function D3DXVec4Minimize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  4687. begin
  4688.   if v1.x < v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  4689.   if v1.y < v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  4690.   if v1.z < v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  4691.   if v1.w < v2.w then vOut.w:= v1.w else vOut.w:= v2.w;
  4692.   Result:= @vOut;
  4693. end;
  4694.  
  4695. // Maximize each component.  x = max(x1, x2), y = max(y1, y2)
  4696. function D3DXVec4Maximize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  4697. begin
  4698.   if v1.x > v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  4699.   if v1.y > v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  4700.   if v1.z > v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  4701.   if v1.w > v2.w then vOut.w:= v1.w else vOut.w:= v2.w;
  4702.   Result:= @vOut;
  4703. end;
  4704.  
  4705. function D3DXVec4Scale(out vOut: TD3DXVector4; const v: TD3DXVector4; s: Single): PD3DXVector4;
  4706. begin
  4707.   with vOut do
  4708.   begin
  4709.     x:= v.x * s; y:= v.y * s; z:= v.z * s; w:= v.w * s;
  4710.   end;
  4711.   Result:= @vOut;
  4712. end;
  4713.  
  4714. // Linear interpolation. V1 + s(V2-V1)
  4715. function D3DXVec4Lerp(out vOut: TD3DXVector4;
  4716.   const v1, v2: TD3DXVector4; s: Single): PD3DXVector4;
  4717. begin
  4718.   with vOut do
  4719.   begin
  4720.     x:= v1.x + s * (v2.x - v1.x);
  4721.     y:= v1.y + s * (v2.y - v1.y);
  4722.     z:= v1.z + s * (v2.z - v1.z);
  4723.     w:= v1.w + s * (v2.w - v1.w);
  4724.   end;
  4725.   Result:= @vOut;
  4726. end;
  4727.  
  4728. //--------------------------
  4729. // 4D Matrix
  4730. //--------------------------
  4731.  
  4732. // inline
  4733. function D3DXMatrixIdentity(out mOut: TD3DXMatrix): PD3DXMatrix;
  4734. begin
  4735.   FillChar(mOut, SizeOf(mOut), 0);
  4736.   mOut._11:= 1; mOut._22:= 1; mOut._33:= 1; mOut._44:= 1;
  4737.   Result:= @mOut;
  4738. end;
  4739.  
  4740. function D3DXMatrixIsIdentity(const m: TD3DXMatrix): BOOL;
  4741. begin
  4742.   with m do Result:=
  4743.     (_11 = 1) and (_12 = 0) and (_13 = 0) and (_14 = 0) and
  4744.     (_21 = 0) and (_22 = 1) and (_23 = 0) and (_24 = 0) and
  4745.     (_31 = 0) and (_32 = 0) and (_33 = 1) and (_34 = 0) and
  4746.     (_41 = 0) and (_42 = 0) and (_43 = 0) and (_44 = 1);
  4747. end;
  4748.  
  4749.  
  4750. //--------------------------
  4751. // Quaternion
  4752. //--------------------------
  4753.  
  4754. // inline
  4755.  
  4756. function D3DXQuaternionLength(const q: TD3DXQuaternion): Single;
  4757. begin
  4758.   with q do Result:= Sqrt(x*x + y*y + z*z + w*w);
  4759. end;
  4760.  
  4761. // Length squared, or "norm"
  4762. function D3DXQuaternionLengthSq(const q: TD3DXQuaternion): Single;
  4763. begin
  4764.   with q do Result:= x*x + y*y + z*z + w*w;
  4765. end;
  4766.  
  4767. function D3DXQuaternionDot(const q1, q2: TD3DXQuaternion): Single;
  4768. begin
  4769.   Result:= q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
  4770. end;
  4771.  
  4772. function D3DXQuaternionIdentity(out qOut: TD3DXQuaternion): PD3DXQuaternion;
  4773. begin
  4774.   with qOut do
  4775.   begin
  4776.     x:= 0; y:= 0; z:= 0; w:= 1.0;
  4777.   end;
  4778.   Result:= @qOut;
  4779. end;
  4780.  
  4781. function D3DXQuaternionIsIdentity(const q: TD3DXQuaternion): BOOL;
  4782. begin
  4783.   with q do Result:= (x = 0) and (y = 0) and (z = 0) and (w = 1);
  4784. end;
  4785.  
  4786. // (-x, -y, -z, w)
  4787. function D3DXQuaternionConjugate(out qOut: TD3DXQuaternion;
  4788.   const q: TD3DXQuaternion): PD3DXQuaternion;
  4789. begin
  4790.   with qOut do
  4791.   begin
  4792.     x:= -q.x; y:= -q.y; z:= -q.z; w:= q.w;
  4793.   end;
  4794.   Result:= @qOut;
  4795. end;
  4796.  
  4797.  
  4798. //--------------------------
  4799. // Plane
  4800. //--------------------------
  4801.  
  4802. // ax + by + cz + dw
  4803. function D3DXPlaneDot(const p: TD3DXPlane; const v: TD3DXVector4): Single;
  4804. begin
  4805.   with p,v do Result:= a*x + b*y + c*z + d*w;
  4806. end;
  4807.  
  4808. // ax + by + cz + d
  4809. function D3DXPlaneDotCoord(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  4810. begin
  4811.   with p,v do Result:= a*x + b*y + c*z + d;
  4812. end;
  4813.  
  4814. // ax + by + cz
  4815. function D3DXPlaneDotNormal(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  4816. begin
  4817.   with p,v do Result:= a*x + b*y + c*z;
  4818. end;
  4819.  
  4820.  
  4821. //--------------------------
  4822. // Color
  4823. //--------------------------
  4824.  
  4825. // inline
  4826.  
  4827. function D3DXColorNegative(out cOut: TD3DXColor; const c: TD3DXColor): PD3DXColor;
  4828. begin
  4829.  with cOut do
  4830.  begin
  4831.    r:= 1.0 - c.r; g:= 1.0 - c.g; b:= 1.0 - c.b;
  4832.    a:= c.a;
  4833.  end;
  4834.  Result:= @cOut;
  4835. end;
  4836.  
  4837. function D3DXColorAdd(out cOut: TD3DXColor; const c1,c2: TD3DXColor): PD3DXColor;
  4838. begin
  4839.   with cOut do
  4840.   begin
  4841.     r:= c1.r + c2.r; g:= c1.g + c2.g; b:= c1.b + c2.b;
  4842.     a:= c1.a + c2.a;
  4843.   end;
  4844.   Result:= @cOut;
  4845. end;
  4846.  
  4847. function D3DXColorSubtract(out cOut: TD3DXColor; const c1,c2: TD3DXColor): PD3DXColor;
  4848. begin
  4849.   with cOut do
  4850.   begin
  4851.     r:= c1.r - c2.r; g:= c1.g - c2.g; b:= c1.b - c2.b;
  4852.     a:= c1.a - c2.a;
  4853.   end;
  4854.   Result:= @cOut;
  4855. end;
  4856.  
  4857. function D3DXColorScale(out cOut: TD3DXColor; const c: TD3DXColor; s: Single): PD3DXColor;
  4858. begin
  4859.   with cOut do
  4860.   begin
  4861.     r:= c.r * s; g:= c.g * s;
  4862.     b:= c.b * s; a:= c.a * s;
  4863.   end;
  4864.   Result:= @cOut;
  4865. end;
  4866.  
  4867. // (r1*r2, g1*g2, b1*b2, a1*a2)
  4868. function D3DXColorModulate(out cOut: TD3DXColor; const c1,c2: TD3DXColor): PD3DXColor;
  4869. begin
  4870.   with cOut do
  4871.   begin
  4872.     r:= c1.r * c2.r; g:= c1.g * c2.g;
  4873.     b:= c1.b * c2.b; a:= c1.a * c2.a;
  4874.   end;
  4875.   Result:= @cOut;
  4876. end;
  4877.  
  4878. // Linear interpolation of r,g,b, and a. C1 + s(C2-C1)
  4879. function D3DXColorLerp(out cOut: TD3DXColor; const c1,c2: TD3DXColor; s: Single): PD3DXColor;
  4880. begin
  4881.   with cOut do
  4882.   begin
  4883.     r:= c1.r + s * (c2.r - c1.r);
  4884.     g:= c1.g + s * (c2.g - c1.g);
  4885.     b:= c1.b + s * (c2.b - c1.b);
  4886.     a:= c1.a + s * (c2.a - c1.a);
  4887.   end;
  4888.   Result:= @cOut;
  4889. end;
  4890.  
  4891.  
  4892.  
  4893.  
  4894. ///////////////////////////////////////////////////////////////////////////
  4895. //
  4896. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  4897. //
  4898. //  File:       d3dx8core.h
  4899. //  Content:    D3DX core types and functions
  4900. //
  4901. ///////////////////////////////////////////////////////////////////////////
  4902.  
  4903.  
  4904. // Object Pascal support functions for D3DXGetErrorString
  4905. function D3DXGetErrorStringA(hr: HResult): String;
  4906. var
  4907.   Buffer: array [0..254] of Char;
  4908. begin
  4909.   D3DXGetErrorString(hr, PAnsiChar(@Buffer), 255);
  4910.   SetLength(Result, StrLen(PAnsiChar(@Buffer)));
  4911.   Move(Buffer, Result[1], Length(Result));
  4912. end;
  4913.  
  4914. function D3DXGetErrorStringW(hr: HResult): WideString;
  4915.  function WStrLen(Str: PWideChar): Integer;
  4916.  begin
  4917.    Result := 0;
  4918.    while Str[Result] <> #0 do Inc(Result);
  4919.  end;
  4920. begin
  4921.   SetLength(Result, 255);
  4922.   D3DXGetErrorStringW(hr, PWideChar(Result), Length(Result));
  4923.   SetLength(Result, WStrLen(PWideChar(Result)));
  4924. end;
  4925.  
  4926.  
  4927. {$IFNDEF UNICODE}
  4928. function D3DXGetErrorString(hr: HResult): String;
  4929. var
  4930.   Buffer: array [0..254] of Char;
  4931. begin
  4932.   D3DXGetErrorString(hr, PAnsiChar(@Buffer), 255);
  4933.   SetLength(Result, StrLen(PAnsiChar(@Buffer)));
  4934.   Move(Buffer, Result[1], Length(Result));
  4935. end;
  4936. {$ELSE}
  4937. function D3DXGetErrorString(hr: HResult): WideString;
  4938.  function WStrLen(Str: PWideChar): Integer;
  4939.  begin
  4940.    Result := 0;
  4941.    while Str[Result] <> #0 do Inc(Result);
  4942.  end;
  4943. begin
  4944.   SetLength(Result, 255);
  4945.   D3DXGetErrorStringW(hr, PWideChar(Result), Length(Result));
  4946.   SetLength(Result, WStrLen(PWideChar(Result)));
  4947. end;
  4948. {$ENDIF}
  4949.  
  4950. end.
  4951.  
  4952.